From 609f1e356accc45d2b83adc177e8059a113c03ee Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 24 Apr 2021 08:43:48 +0100 Subject: [PATCH 1/3] Add the USDP metadata header to the FM network output. --- FMControl.cpp | 2 +- FMNetwork.cpp | 138 ++++++++++++++++++++++++++++++++++++++++++++++---- FMNetwork.h | 7 ++- MMDVMHost.cpp | 3 +- Version.h | 2 +- 5 files changed, 136 insertions(+), 16 deletions(-) diff --git a/FMControl.cpp b/FMControl.cpp index 1708c61..18d3e85 100644 --- a/FMControl.cpp +++ b/FMControl.cpp @@ -79,7 +79,7 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length) return true; if (data[0U] == TAG_EOT) - return m_network->writeEOT(); + return m_network->writeEnd(); if (data[0U] != TAG_DATA1) return false; diff --git a/FMNetwork.cpp b/FMNetwork.cpp index 2deed38..09828e7 100644 --- a/FMNetwork.cpp +++ b/FMNetwork.cpp @@ -27,7 +27,8 @@ const unsigned int BUFFER_LENGTH = 1500U; -CFMNetwork::CFMNetwork(const std::string& protocol, const std::string& localAddress, unsigned int localPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug) : +CFMNetwork::CFMNetwork(const std::string& callsign, const std::string& protocol, const std::string& localAddress, unsigned int localPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug) : +m_callsign(callsign), m_protocol(FMNP_USRP), m_socket(localAddress, localPort), m_addr(), @@ -37,12 +38,18 @@ m_enabled(false), m_buffer(2000U, "FM Network"), m_seqNo(0U) { + assert(!callsign.empty()); assert(gatewayPort > 0U); assert(!gatewayAddress.empty()); if (CUDPSocket::lookup(gatewayAddress, gatewayPort, m_addr, m_addrLen) != 0) m_addrLen = 0U; + // Remove any trailing letters in the callsign + size_t pos = callsign.find_first_of(' '); + if (pos != std::string::npos) + m_callsign = callsign.substr(0U, pos); + // if (protocol == "USRP") // m_protocol = FMNP_USRP; } @@ -68,8 +75,14 @@ bool CFMNetwork::writeData(float* data, unsigned int nSamples) assert(data != NULL); assert(nSamples > 0U); - unsigned char buffer[1500U]; - ::memset(buffer, 0x00U, 1500U); + if (m_seqNo == 0U) { + bool ret = writeStart(); + if (!ret) + return false; + } + + unsigned char buffer[500U]; + ::memset(buffer, 0x00U, 500U); unsigned int length = 0U; @@ -133,10 +146,10 @@ bool CFMNetwork::writeData(float* data, unsigned int nSamples) return m_socket.write(buffer, length, m_addr, m_addrLen); } -bool CFMNetwork::writeEOT() +bool CFMNetwork::writeEnd() { - unsigned char buffer[1500U]; - ::memset(buffer, 0x00U, 1500U); + unsigned char buffer[500U]; + ::memset(buffer, 0x00U, 500U); unsigned int length = 0U; @@ -184,15 +197,19 @@ bool CFMNetwork::writeEOT() buffer[length++] = 0x00U; buffer[length++] = 0x00U; - length += 160U * sizeof(int16_t); + length += 320U; } - if (m_debug) - CUtils::dump(1U, "FM Network Data Sent", buffer, length); + m_seqNo = 0U; - m_seqNo++; + if (length > 0U) { + if (m_debug) + CUtils::dump(1U, "FM Network Data Sent", buffer, length); - return m_socket.write(buffer, length, m_addr, m_addrLen); + return m_socket.write(buffer, length, m_addr, m_addrLen); + } else { + return true; + } } void CFMNetwork::clock(unsigned int ms) @@ -280,3 +297,102 @@ void CFMNetwork::enable(bool enabled) m_enabled = enabled; } + +bool CFMNetwork::writeStart() +{ + unsigned char buffer[500U]; + ::memset(buffer, 0x00U, 500U); + + unsigned int length = 0U; + + if (m_protocol == FMNP_USRP) { + buffer[length++] = 'U'; + buffer[length++] = 'S'; + buffer[length++] = 'R'; + buffer[length++] = 'P'; + + // Sequence number + buffer[length++] = (m_seqNo >> 24) & 0xFFU; + buffer[length++] = (m_seqNo >> 16) & 0xFFU; + buffer[length++] = (m_seqNo >> 8) & 0xFFU; + buffer[length++] = (m_seqNo >> 0) & 0xFFU; + + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + + // PTT off + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + + // Type, 2 for metadata + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x02U; + + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + + // TLV TAG for Metadata + buffer[length++] = 0x08U; + + // TLV Length + buffer[length++] = 3U + 4U + 3U + 1U + 1U + m_callsign.size() + 1U; + + // DMR Id + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + + // Rpt Id + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + + // Talk Group + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + buffer[length++] = 0x00U; + + // Time Slot + buffer[length++] = 0x00U; + + // Color Code + buffer[length++] = 0x00U; + + // Callsign + for (std::string::const_iterator it = m_callsign.cbegin(); it != m_callsign.cend(); ++it) + buffer[length++] = *it; + + // End of Metadata + buffer[length++] = 0x00U; + + length = 70U; + } + + if (length > 0U) { + if (m_debug) + CUtils::dump(1U, "FM Network Data Sent", buffer, length); + + return m_socket.write(buffer, length, m_addr, m_addrLen); + } else { + return true; + } +} diff --git a/FMNetwork.h b/FMNetwork.h index 0696599..e3f58de 100644 --- a/FMNetwork.h +++ b/FMNetwork.h @@ -31,7 +31,7 @@ enum FM_NETWORK_PROTOCOL { class CFMNetwork { public: - CFMNetwork(const std::string& protocol, const std::string& myAddress, unsigned int myPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug); + CFMNetwork(const std::string& callsign, const std::string& protocol, const std::string& myAddress, unsigned int myPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug); ~CFMNetwork(); bool open(); @@ -40,7 +40,7 @@ public: bool writeData(float* data, unsigned int nSamples); - bool writeEOT(); + bool writeEnd(); unsigned int read(float* data, unsigned int nSamples); @@ -51,6 +51,7 @@ public: void clock(unsigned int ms); private: + std::string m_callsign; FM_NETWORK_PROTOCOL m_protocol; CUDPSocket m_socket; sockaddr_storage m_addr; @@ -59,6 +60,8 @@ private: bool m_enabled; CRingBuffer m_buffer; unsigned int m_seqNo; + + bool writeStart(); }; #endif diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 55e393b..6fa7034 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1800,6 +1800,7 @@ bool CMMDVMHost::createPOCSAGNetwork() bool CMMDVMHost::createFMNetwork() { + std::string callsign = m_conf.getFMCallsign(); std::string protocol = m_conf.getFMNetworkProtocol(); std::string gatewayAddress = m_conf.getFMGatewayAddress(); unsigned int gatewayPort = m_conf.getFMGatewayPort(); @@ -1824,7 +1825,7 @@ bool CMMDVMHost::createFMNetwork() LogInfo(" RX Audio Gain: %.2f", rxAudioGain); LogInfo(" Mode Hang: %us", m_fmNetModeHang); - m_fmNetwork = new CFMNetwork(protocol, localAddress, localPort, gatewayAddress, gatewayPort, debug); + m_fmNetwork = new CFMNetwork(callsign, protocol, localAddress, localPort, gatewayAddress, gatewayPort, debug); bool ret = m_fmNetwork->open(); if (!ret) { diff --git a/Version.h b/Version.h index 4498807..b9a0ca6 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20210420"; +const char* VERSION = "20210424"; #endif From ec0bc51899b459ba4fc69aa7c433cf874471886a Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Sun, 25 Apr 2021 07:47:06 +0200 Subject: [PATCH 2/3] Fix network ports datatype (unsigned int -> unsigned short). UDPSocket: fix old bug using m_port instead of m_port[x]. --- Conf.cpp | 68 +++++++++++++++++++++--------------------- Conf.h | 68 +++++++++++++++++++++--------------------- DMRDirectNetwork.cpp | 2 +- DMRDirectNetwork.h | 4 +-- DMRGatewayNetwork.cpp | 2 +- DMRGatewayNetwork.h | 4 +-- DStarNetwork.cpp | 2 +- DStarNetwork.h | 2 +- LCDproc.cpp | 2 +- LCDproc.h | 4 +-- MMDVMHost.cpp | 62 +++++++++++++++++++------------------- NXDNIcomNetwork.cpp | 2 +- NXDNIcomNetwork.h | 2 +- NXDNKenwoodNetwork.cpp | 2 +- NXDNKenwoodNetwork.h | 2 +- P25Network.cpp | 2 +- P25Network.h | 2 +- POCSAGNetwork.cpp | 2 +- POCSAGNetwork.h | 2 +- UDPSocket.cpp | 14 ++++----- UDPSocket.h | 10 +++---- YSFNetwork.cpp | 2 +- YSFNetwork.h | 2 +- 23 files changed, 132 insertions(+), 132 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index f9c1300..580bd98 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -535,9 +535,9 @@ bool CConf::read() else if (::strcmp(key, "RemoteAddress") == 0) m_transparentRemoteAddress = value; else if (::strcmp(key, "RemotePort") == 0) - m_transparentRemotePort = (unsigned int)::atoi(value); + m_transparentRemotePort = (unsigned short)::atoi(value); else if (::strcmp(key, "LocalPort") == 0) - m_transparentLocalPort = (unsigned int)::atoi(value); + m_transparentLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "SendFrameType") == 0) m_transparentSendFrameType = (unsigned int)::atoi(value); } else if (section == SECTION_UMP) { @@ -806,9 +806,9 @@ bool CConf::read() else if (::strcmp(key, "GatewayAddress") == 0) m_dstarGatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) - m_dstarGatewayPort = (unsigned int)::atoi(value); + m_dstarGatewayPort = (unsigned short)::atoi(value); else if (::strcmp(key, "LocalPort") == 0) - m_dstarLocalPort = (unsigned int)::atoi(value); + m_dstarLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_dstarNetworkModeHang = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) @@ -821,9 +821,9 @@ bool CConf::read() else if (::strcmp(key, "Address") == 0) m_dmrNetworkAddress = value; else if (::strcmp(key, "Port") == 0) - m_dmrNetworkPort = (unsigned int)::atoi(value); + m_dmrNetworkPort = (unsigned short)::atoi(value); else if (::strcmp(key, "Local") == 0) - m_dmrNetworkLocal = (unsigned int)::atoi(value); + m_dmrNetworkLocal = (unsigned short)::atoi(value); else if (::strcmp(key, "Password") == 0) m_dmrNetworkPassword = value; else if (::strcmp(key, "Options") == 0) @@ -844,11 +844,11 @@ bool CConf::read() else if (::strcmp(key, "LocalAddress") == 0) m_fusionNetworkMyAddress = value; else if (::strcmp(key, "LocalPort") == 0) - m_fusionNetworkMyPort = (unsigned int)::atoi(value); + m_fusionNetworkMyPort = (unsigned short)::atoi(value); else if (::strcmp(key, "GatewayAddress") == 0) m_fusionNetworkGatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) - m_fusionNetworkGatewayPort = (unsigned int)::atoi(value); + m_fusionNetworkGatewayPort = (unsigned short)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_fusionNetworkModeHang = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) @@ -859,9 +859,9 @@ bool CConf::read() else if (::strcmp(key, "GatewayAddress") == 0) m_p25GatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) - m_p25GatewayPort = (unsigned int)::atoi(value); + m_p25GatewayPort = (unsigned short)::atoi(value); else if (::strcmp(key, "LocalPort") == 0) - m_p25LocalPort = (unsigned int)::atoi(value); + m_p25LocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_p25NetworkModeHang = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) @@ -874,11 +874,11 @@ bool CConf::read() else if (::strcmp(key, "LocalAddress") == 0) m_nxdnLocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) - m_nxdnLocalPort = (unsigned int)::atoi(value); + m_nxdnLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "GatewayAddress") == 0) m_nxdnGatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) - m_nxdnGatewayPort = (unsigned int)::atoi(value); + m_nxdnGatewayPort = (unsigned short)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_nxdnNetworkModeHang = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) @@ -889,11 +889,11 @@ bool CConf::read() else if (::strcmp(key, "LocalAddress") == 0) m_pocsagLocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) - m_pocsagLocalPort = (unsigned int)::atoi(value); + m_pocsagLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "GatewayAddress") == 0) m_pocsagGatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) - m_pocsagGatewayPort = (unsigned int)::atoi(value); + m_pocsagGatewayPort = (unsigned short)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_pocsagNetworkModeHang = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) @@ -962,9 +962,9 @@ bool CConf::read() if (::strcmp(key, "Address") == 0) m_lcdprocAddress = value; else if (::strcmp(key, "Port") == 0) - m_lcdprocPort = (unsigned int)::atoi(value); + m_lcdprocPort = (unsigned short)::atoi(value); else if (::strcmp(key, "LocalPort") == 0) - m_lcdprocLocalPort = (unsigned int)::atoi(value); + m_lcdprocLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "DisplayClock") == 0) m_lcdprocDisplayClock = ::atoi(value) == 1; else if (::strcmp(key, "UTC") == 0) @@ -982,7 +982,7 @@ bool CConf::read() else if (::strcmp(key, "Address") == 0) m_remoteControlAddress = value; else if (::strcmp(key, "Port") == 0) - m_remoteControlPort = (unsigned int)::atoi(value); + m_remoteControlPort = (unsigned short)::atoi(value); } } @@ -1266,12 +1266,12 @@ std::string CConf::getTransparentRemoteAddress() const return m_transparentRemoteAddress; } -unsigned int CConf::getTransparentRemotePort() const +unsigned short CConf::getTransparentRemotePort() const { return m_transparentRemotePort; } -unsigned int CConf::getTransparentLocalPort() const +unsigned short CConf::getTransparentLocalPort() const { return m_transparentLocalPort; } @@ -1716,12 +1716,12 @@ std::string CConf::getDStarGatewayAddress() const return m_dstarGatewayAddress; } -unsigned int CConf::getDStarGatewayPort() const +unsigned short CConf::getDStarGatewayPort() const { return m_dstarGatewayPort; } -unsigned int CConf::getDStarLocalPort() const +unsigned short CConf::getDStarLocalPort() const { return m_dstarLocalPort; } @@ -1751,12 +1751,12 @@ std::string CConf::getDMRNetworkAddress() const return m_dmrNetworkAddress; } -unsigned int CConf::getDMRNetworkPort() const +unsigned short CConf::getDMRNetworkPort() const { return m_dmrNetworkPort; } -unsigned int CConf::getDMRNetworkLocal() const +unsigned short CConf::getDMRNetworkLocal() const { return m_dmrNetworkLocal; } @@ -1806,7 +1806,7 @@ std::string CConf::getFusionNetworkMyAddress() const return m_fusionNetworkMyAddress; } -unsigned int CConf::getFusionNetworkMyPort() const +unsigned short CConf::getFusionNetworkMyPort() const { return m_fusionNetworkMyPort; } @@ -1816,7 +1816,7 @@ std::string CConf::getFusionNetworkGatewayAddress() const return m_fusionNetworkGatewayAddress; } -unsigned int CConf::getFusionNetworkGatewayPort() const +unsigned short CConf::getFusionNetworkGatewayPort() const { return m_fusionNetworkGatewayPort; } @@ -1841,12 +1841,12 @@ std::string CConf::getP25GatewayAddress() const return m_p25GatewayAddress; } -unsigned int CConf::getP25GatewayPort() const +unsigned short CConf::getP25GatewayPort() const { return m_p25GatewayPort; } -unsigned int CConf::getP25LocalPort() const +unsigned short CConf::getP25LocalPort() const { return m_p25LocalPort; } @@ -1876,7 +1876,7 @@ std::string CConf::getNXDNGatewayAddress() const return m_nxdnGatewayAddress; } -unsigned int CConf::getNXDNGatewayPort() const +unsigned short CConf::getNXDNGatewayPort() const { return m_nxdnGatewayPort; } @@ -1886,7 +1886,7 @@ std::string CConf::getNXDNLocalAddress() const return m_nxdnLocalAddress; } -unsigned int CConf::getNXDNLocalPort() const +unsigned short CConf::getNXDNLocalPort() const { return m_nxdnLocalPort; } @@ -1911,7 +1911,7 @@ std::string CConf::getPOCSAGGatewayAddress() const return m_pocsagGatewayAddress; } -unsigned int CConf::getPOCSAGGatewayPort() const +unsigned short CConf::getPOCSAGGatewayPort() const { return m_pocsagGatewayPort; } @@ -1921,7 +1921,7 @@ std::string CConf::getPOCSAGLocalAddress() const return m_pocsagLocalAddress; } -unsigned int CConf::getPOCSAGLocalPort() const +unsigned short CConf::getPOCSAGLocalPort() const { return m_pocsagLocalPort; } @@ -2062,12 +2062,12 @@ std::string CConf::getLCDprocAddress() const return m_lcdprocAddress; } -unsigned int CConf::getLCDprocPort() const +unsigned short CConf::getLCDprocPort() const { return m_lcdprocPort; } -unsigned int CConf::getLCDprocLocalPort() const +unsigned short CConf::getLCDprocLocalPort() const { return m_lcdprocLocalPort; } @@ -2112,7 +2112,7 @@ std::string CConf::getRemoteControlAddress() const return m_remoteControlAddress; } -unsigned int CConf::getRemoteControlPort() const +unsigned short CConf::getRemoteControlPort() const { return m_remoteControlPort; } diff --git a/Conf.h b/Conf.h index da2f78e..5e5a7d3 100644 --- a/Conf.h +++ b/Conf.h @@ -100,8 +100,8 @@ public: // The Transparent Data section bool getTransparentEnabled() const; std::string getTransparentRemoteAddress() const; - unsigned int getTransparentRemotePort() const; - unsigned int getTransparentLocalPort() const; + unsigned short getTransparentRemotePort() const; + unsigned short getTransparentLocalPort() const; unsigned int getTransparentSendFrameType() const; // The UMP section @@ -208,8 +208,8 @@ public: // The D-Star Network section bool getDStarNetworkEnabled() const; std::string getDStarGatewayAddress() const; - unsigned int getDStarGatewayPort() const; - unsigned int getDStarLocalPort() const; + unsigned short getDStarGatewayPort() const; + unsigned short getDStarLocalPort() const; unsigned int getDStarNetworkModeHang() const; bool getDStarNetworkDebug() const; @@ -217,8 +217,8 @@ public: bool getDMRNetworkEnabled() const; std::string getDMRNetworkType() const; std::string getDMRNetworkAddress() const; - unsigned int getDMRNetworkPort() const; - unsigned int getDMRNetworkLocal() const; + unsigned short getDMRNetworkPort() const; + unsigned short getDMRNetworkLocal() const; std::string getDMRNetworkPassword() const; std::string getDMRNetworkOptions() const; bool getDMRNetworkDebug() const; @@ -230,17 +230,17 @@ public: // The System Fusion Network section bool getFusionNetworkEnabled() const; std::string getFusionNetworkMyAddress() const; - unsigned int getFusionNetworkMyPort() const; + unsigned short getFusionNetworkMyPort() const; std::string getFusionNetworkGatewayAddress() const; - unsigned int getFusionNetworkGatewayPort() const; + unsigned short getFusionNetworkGatewayPort() const; unsigned int getFusionNetworkModeHang() const; bool getFusionNetworkDebug() const; // The P25 Network section bool getP25NetworkEnabled() const; std::string getP25GatewayAddress() const; - unsigned int getP25GatewayPort() const; - unsigned int getP25LocalPort() const; + unsigned short getP25GatewayPort() const; + unsigned short getP25LocalPort() const; unsigned int getP25NetworkModeHang() const; bool getP25NetworkDebug() const; @@ -248,18 +248,18 @@ public: bool getNXDNNetworkEnabled() const; std::string getNXDNNetworkProtocol() const; std::string getNXDNGatewayAddress() const; - unsigned int getNXDNGatewayPort() const; + unsigned short getNXDNGatewayPort() const; std::string getNXDNLocalAddress() const; - unsigned int getNXDNLocalPort() const; + unsigned short getNXDNLocalPort() const; unsigned int getNXDNNetworkModeHang() const; bool getNXDNNetworkDebug() const; // The POCSAG Network section bool getPOCSAGNetworkEnabled() const; std::string getPOCSAGGatewayAddress() const; - unsigned int getPOCSAGGatewayPort() const; + unsigned short getPOCSAGGatewayPort() const; std::string getPOCSAGLocalAddress() const; - unsigned int getPOCSAGLocalPort() const; + unsigned short getPOCSAGLocalPort() const; unsigned int getPOCSAGNetworkModeHang() const; bool getPOCSAGNetworkDebug() const; @@ -298,8 +298,8 @@ public: // The LCDproc section std::string getLCDprocAddress() const; - unsigned int getLCDprocPort() const; - unsigned int getLCDprocLocalPort() const; + unsigned short getLCDprocPort() const; + unsigned short getLCDprocLocalPort() const; bool getLCDprocDisplayClock() const; bool getLCDprocUTC() const; bool getLCDprocDimOnIdle() const; @@ -311,7 +311,7 @@ public: // The Remote Control section bool getRemoteControlEnabled() const; std::string getRemoteControlAddress() const; - unsigned int getRemoteControlPort() const; + unsigned short getRemoteControlPort() const; private: std::string m_file; @@ -377,8 +377,8 @@ private: bool m_transparentEnabled; std::string m_transparentRemoteAddress; - unsigned int m_transparentRemotePort; - unsigned int m_transparentLocalPort; + unsigned short m_transparentRemotePort; + unsigned short m_transparentLocalPort; unsigned int m_transparentSendFrameType; bool m_umpEnabled; @@ -476,16 +476,16 @@ private: bool m_dstarNetworkEnabled; std::string m_dstarGatewayAddress; - unsigned int m_dstarGatewayPort; - unsigned int m_dstarLocalPort; + unsigned short m_dstarGatewayPort; + unsigned short m_dstarLocalPort; unsigned int m_dstarNetworkModeHang; bool m_dstarNetworkDebug; bool m_dmrNetworkEnabled; std::string m_dmrNetworkType; std::string m_dmrNetworkAddress; - unsigned int m_dmrNetworkPort; - unsigned int m_dmrNetworkLocal; + unsigned short m_dmrNetworkPort; + unsigned short m_dmrNetworkLocal; std::string m_dmrNetworkPassword; std::string m_dmrNetworkOptions; bool m_dmrNetworkDebug; @@ -496,33 +496,33 @@ private: bool m_fusionNetworkEnabled; std::string m_fusionNetworkMyAddress; - unsigned int m_fusionNetworkMyPort; + unsigned short m_fusionNetworkMyPort; std::string m_fusionNetworkGatewayAddress; - unsigned int m_fusionNetworkGatewayPort; + unsigned short m_fusionNetworkGatewayPort; unsigned int m_fusionNetworkModeHang; bool m_fusionNetworkDebug; bool m_p25NetworkEnabled; std::string m_p25GatewayAddress; - unsigned int m_p25GatewayPort; - unsigned int m_p25LocalPort; + unsigned short m_p25GatewayPort; + unsigned short m_p25LocalPort; unsigned int m_p25NetworkModeHang; bool m_p25NetworkDebug; bool m_nxdnNetworkEnabled; std::string m_nxdnNetworkProtocol; std::string m_nxdnGatewayAddress; - unsigned int m_nxdnGatewayPort; + unsigned short m_nxdnGatewayPort; std::string m_nxdnLocalAddress; - unsigned int m_nxdnLocalPort; + unsigned short m_nxdnLocalPort; unsigned int m_nxdnNetworkModeHang; bool m_nxdnNetworkDebug; bool m_pocsagNetworkEnabled; std::string m_pocsagGatewayAddress; - unsigned int m_pocsagGatewayPort; + unsigned short m_pocsagGatewayPort; std::string m_pocsagLocalAddress; - unsigned int m_pocsagLocalPort; + unsigned short m_pocsagLocalPort; unsigned int m_pocsagNetworkModeHang; bool m_pocsagNetworkDebug; @@ -556,8 +556,8 @@ private: bool m_oledLogoScreensaver; std::string m_lcdprocAddress; - unsigned int m_lcdprocPort; - unsigned int m_lcdprocLocalPort; + unsigned short m_lcdprocPort; + unsigned short m_lcdprocLocalPort; bool m_lcdprocDisplayClock; bool m_lcdprocUTC; bool m_lcdprocDimOnIdle; @@ -567,7 +567,7 @@ private: bool m_remoteControlEnabled; std::string m_remoteControlAddress; - unsigned int m_remoteControlPort; + unsigned short m_remoteControlPort; }; #endif diff --git a/DMRDirectNetwork.cpp b/DMRDirectNetwork.cpp index a27a646..04886c1 100644 --- a/DMRDirectNetwork.cpp +++ b/DMRDirectNetwork.cpp @@ -30,7 +30,7 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; -CDMRDirectNetwork::CDMRDirectNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) : +CDMRDirectNetwork::CDMRDirectNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) : m_address(address), m_port(port), m_addr(), diff --git a/DMRDirectNetwork.h b/DMRDirectNetwork.h index 6df82cc..6ebff40 100644 --- a/DMRDirectNetwork.h +++ b/DMRDirectNetwork.h @@ -32,7 +32,7 @@ class CDMRDirectNetwork : public IDMRNetwork { public: - CDMRDirectNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug); + CDMRDirectNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug); virtual ~CDMRDirectNetwork(); virtual void setOptions(const std::string& options); @@ -61,7 +61,7 @@ public: private: std::string m_address; - unsigned int m_port; + unsigned short m_port; sockaddr_storage m_addr; unsigned int m_addrLen; uint8_t* m_id; diff --git a/DMRGatewayNetwork.cpp b/DMRGatewayNetwork.cpp index f6dfe47..fe4cda8 100644 --- a/DMRGatewayNetwork.cpp +++ b/DMRGatewayNetwork.cpp @@ -31,7 +31,7 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; -CDMRGatewayNetwork::CDMRGatewayNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) : +CDMRGatewayNetwork::CDMRGatewayNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) : m_addressStr(address), m_addr(), m_addrLen(0U), diff --git a/DMRGatewayNetwork.h b/DMRGatewayNetwork.h index 7bca94f..5979a3a 100644 --- a/DMRGatewayNetwork.h +++ b/DMRGatewayNetwork.h @@ -33,7 +33,7 @@ class CDMRGatewayNetwork : public IDMRNetwork { public: - CDMRGatewayNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug); + CDMRGatewayNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug); virtual ~CDMRGatewayNetwork(); virtual void setOptions(const std::string& options); @@ -64,7 +64,7 @@ private: std::string m_addressStr; sockaddr_storage m_addr; unsigned int m_addrLen; - unsigned int m_port; + unsigned short m_port; uint8_t* m_id; bool m_duplex; const char* m_version; diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index c702cfa..3abcd47 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -30,7 +30,7 @@ const unsigned int BUFFER_LENGTH = 100U; -CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug) : +CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool duplex, const char* version, bool debug) : m_socket(localPort), m_addr(), m_addrLen(0U), diff --git a/DStarNetwork.h b/DStarNetwork.h index cb41b78..8ecd5ac 100644 --- a/DStarNetwork.h +++ b/DStarNetwork.h @@ -30,7 +30,7 @@ class CDStarNetwork { public: - CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug); + CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool duplex, const char* version, bool debug); ~CDStarNetwork(); bool open(); diff --git a/LCDproc.cpp b/LCDproc.cpp index 19ac15e..e6225a5 100644 --- a/LCDproc.cpp +++ b/LCDproc.cpp @@ -96,7 +96,7 @@ const unsigned int YSF_RSSI_COUNT = 13U; // 13 * 100ms = 1300ms const unsigned int P25_RSSI_COUNT = 7U; // 7 * 180ms = 1260ms const unsigned int NXDN_RSSI_COUNT = 28U; // 28 * 40ms = 1120ms -CLCDproc::CLCDproc(std::string address, unsigned int port, unsigned int localPort, const std::string& callsign, unsigned int dmrid, bool displayClock, bool utc, bool duplex, bool dimOnIdle) : +CLCDproc::CLCDproc(std::string address, unsigned int port, unsigned short localPort, const std::string& callsign, unsigned int dmrid, bool displayClock, bool utc, bool duplex, bool dimOnIdle) : CDisplay(), m_address(address), m_port(port), diff --git a/LCDproc.h b/LCDproc.h index 896e8a6..a6e6e6b 100644 --- a/LCDproc.h +++ b/LCDproc.h @@ -28,7 +28,7 @@ class CLCDproc : public CDisplay { public: - CLCDproc(std::string address, unsigned int port, unsigned int localPort, const std::string& callsign, unsigned int dmrid, bool displayClock, bool utc, bool duplex, bool dimOnIdle); + CLCDproc(std::string address, unsigned int port, unsigned short localPort, const std::string& callsign, unsigned int dmrid, bool displayClock, bool utc, bool duplex, bool dimOnIdle); virtual ~CLCDproc(); virtual bool open(); @@ -73,7 +73,7 @@ protected: private: std::string m_address; unsigned int m_port; - unsigned int m_localPort; + unsigned short m_localPort; std::string m_callsign; unsigned int m_dmrid; bool m_displayClock; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index ab8b5b1..2161f17 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -339,14 +339,14 @@ int CMMDVMHost::run() unsigned int sendFrameType = 0U; if (m_conf.getTransparentEnabled()) { std::string remoteAddress = m_conf.getTransparentRemoteAddress(); - unsigned int remotePort = m_conf.getTransparentRemotePort(); - unsigned int localPort = m_conf.getTransparentLocalPort(); + unsigned short remotePort = m_conf.getTransparentRemotePort(); + unsigned short localPort = m_conf.getTransparentLocalPort(); sendFrameType = m_conf.getTransparentSendFrameType(); LogInfo("Transparent Data"); LogInfo(" Remote Address: %s", remoteAddress.c_str()); - LogInfo(" Remote Port: %u", remotePort); - LogInfo(" Local Port: %u", localPort); + LogInfo(" Remote Port: %hu", remotePort); + LogInfo(" Local Port: %hu", localPort); LogInfo(" Send Frame Type: %u", sendFrameType); if (CUDPSocket::lookup(remoteAddress, remotePort, transparentAddress, transparentAddrLen) != 0) { @@ -629,11 +629,11 @@ int CMMDVMHost::run() bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); if (remoteControlEnabled) { std::string address = m_conf.getRemoteControlAddress(); - unsigned int port = m_conf.getRemoteControlPort(); + unsigned short port = m_conf.getRemoteControlPort(); LogInfo("Remote Control Parameters"); LogInfo(" Address: %s", address.c_str()); - LogInfo(" Port: %u", port); + LogInfo(" Port: %hu", port); m_remoteControl = new CRemoteControl(this, address, port); @@ -1265,7 +1265,7 @@ bool CMMDVMHost::createModem() bool cosInvert = m_conf.getFMCOSInvert(); unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); float maxDevLevel = m_conf.getFMMaxDevLevel(); - unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); + //unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); LogInfo("FM Parameters"); LogInfo(" Callsign: %s", callsign.c_str()); @@ -1317,15 +1317,15 @@ bool CMMDVMHost::createModem() bool CMMDVMHost::createDStarNetwork() { std::string gatewayAddress = m_conf.getDStarGatewayAddress(); - unsigned int gatewayPort = m_conf.getDStarGatewayPort(); - unsigned int localPort = m_conf.getDStarLocalPort(); + unsigned short gatewayPort = m_conf.getDStarGatewayPort(); + unsigned short localPort = m_conf.getDStarLocalPort(); bool debug = m_conf.getDStarNetworkDebug(); m_dstarNetModeHang = m_conf.getDStarNetworkModeHang(); LogInfo("D-Star Network Parameters"); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); - LogInfo(" Gateway Port: %u", gatewayPort); - LogInfo(" Local Port: %u", localPort); + LogInfo(" Gateway Port: %hu", gatewayPort); + LogInfo(" Local Port: %hu", localPort); LogInfo(" Mode Hang: %us", m_dstarNetModeHang); m_dstarNetwork = new CDStarNetwork(gatewayAddress, gatewayPort, localPort, m_duplex, VERSION, debug); @@ -1345,8 +1345,8 @@ bool CMMDVMHost::createDStarNetwork() bool CMMDVMHost::createDMRNetwork() { std::string address = m_conf.getDMRNetworkAddress(); - unsigned int port = m_conf.getDMRNetworkPort(); - unsigned int local = m_conf.getDMRNetworkLocal(); + unsigned short port = m_conf.getDMRNetworkPort(); + unsigned short local = m_conf.getDMRNetworkLocal(); unsigned int id = m_conf.getDMRId(); std::string password = m_conf.getDMRNetworkPassword(); bool debug = m_conf.getDMRNetworkDebug(); @@ -1362,9 +1362,9 @@ bool CMMDVMHost::createDMRNetwork() LogInfo("DMR Network Parameters"); LogInfo(" Type: %s", type.c_str()); LogInfo(" Address: %s", address.c_str()); - LogInfo(" Port: %u", port); + LogInfo(" Port: %hu", port); if (local > 0U) - LogInfo(" Local: %u", local); + LogInfo(" Local: %hu", local); else LogInfo(" Local: random"); LogInfo(" Jitter: %ums", jitter); @@ -1429,17 +1429,17 @@ bool CMMDVMHost::createDMRNetwork() bool CMMDVMHost::createYSFNetwork() { std::string myAddress = m_conf.getFusionNetworkMyAddress(); - unsigned int myPort = m_conf.getFusionNetworkMyPort(); + unsigned short myPort = m_conf.getFusionNetworkMyPort(); std::string gatewayAddress = m_conf.getFusionNetworkGatewayAddress(); - unsigned int gatewayPort = m_conf.getFusionNetworkGatewayPort(); + unsigned short gatewayPort = m_conf.getFusionNetworkGatewayPort(); m_ysfNetModeHang = m_conf.getFusionNetworkModeHang(); bool debug = m_conf.getFusionNetworkDebug(); LogInfo("System Fusion Network Parameters"); LogInfo(" Local Address: %s", myAddress.c_str()); - LogInfo(" Local Port: %u", myPort); + LogInfo(" Local Port: %hu", myPort); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); - LogInfo(" Gateway Port: %u", gatewayPort); + LogInfo(" Gateway Port: %hu", gatewayPort); LogInfo(" Mode Hang: %us", m_ysfNetModeHang); m_ysfNetwork = new CYSFNetwork(myAddress, myPort, gatewayAddress, gatewayPort, m_callsign, debug); @@ -1459,15 +1459,15 @@ bool CMMDVMHost::createYSFNetwork() bool CMMDVMHost::createP25Network() { std::string gatewayAddress = m_conf.getP25GatewayAddress(); - unsigned int gatewayPort = m_conf.getP25GatewayPort(); - unsigned int localPort = m_conf.getP25LocalPort(); + unsigned short gatewayPort = m_conf.getP25GatewayPort(); + unsigned short localPort = m_conf.getP25LocalPort(); m_p25NetModeHang = m_conf.getP25NetworkModeHang(); bool debug = m_conf.getP25NetworkDebug(); LogInfo("P25 Network Parameters"); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); - LogInfo(" Gateway Port: %u", gatewayPort); - LogInfo(" Local Port: %u", localPort); + LogInfo(" Gateway Port: %hu", gatewayPort); + LogInfo(" Local Port: %hu", localPort); LogInfo(" Mode Hang: %us", m_p25NetModeHang); m_p25Network = new CP25Network(gatewayAddress, gatewayPort, localPort, debug); @@ -1488,18 +1488,18 @@ bool CMMDVMHost::createNXDNNetwork() { std::string protocol = m_conf.getNXDNNetworkProtocol(); std::string gatewayAddress = m_conf.getNXDNGatewayAddress(); - unsigned int gatewayPort = m_conf.getNXDNGatewayPort(); + unsigned short gatewayPort = m_conf.getNXDNGatewayPort(); std::string localAddress = m_conf.getNXDNLocalAddress(); - unsigned int localPort = m_conf.getNXDNLocalPort(); + unsigned short localPort = m_conf.getNXDNLocalPort(); m_nxdnNetModeHang = m_conf.getNXDNNetworkModeHang(); bool debug = m_conf.getNXDNNetworkDebug(); LogInfo("NXDN Network Parameters"); LogInfo(" Protocol: %s", protocol.c_str()); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); - LogInfo(" Gateway Port: %u", gatewayPort); + LogInfo(" Gateway Port: %hu", gatewayPort); LogInfo(" Local Address: %s", localAddress.c_str()); - LogInfo(" Local Port: %u", localPort); + LogInfo(" Local Port: %hu", localPort); LogInfo(" Mode Hang: %us", m_nxdnNetModeHang); if (protocol == "Kenwood") @@ -1522,17 +1522,17 @@ bool CMMDVMHost::createNXDNNetwork() bool CMMDVMHost::createPOCSAGNetwork() { std::string gatewayAddress = m_conf.getPOCSAGGatewayAddress(); - unsigned int gatewayPort = m_conf.getPOCSAGGatewayPort(); + unsigned short gatewayPort = m_conf.getPOCSAGGatewayPort(); std::string localAddress = m_conf.getPOCSAGLocalAddress(); - unsigned int localPort = m_conf.getPOCSAGLocalPort(); + unsigned short localPort = m_conf.getPOCSAGLocalPort(); m_pocsagNetModeHang = m_conf.getPOCSAGNetworkModeHang(); bool debug = m_conf.getPOCSAGNetworkDebug(); LogInfo("POCSAG Network Parameters"); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); - LogInfo(" Gateway Port: %u", gatewayPort); + LogInfo(" Gateway Port: %hu", gatewayPort); LogInfo(" Local Address: %s", localAddress.c_str()); - LogInfo(" Local Port: %u", localPort); + LogInfo(" Local Port: %hu", localPort); LogInfo(" Mode Hang: %us", m_pocsagNetModeHang); m_pocsagNetwork = new CPOCSAGNetwork(localAddress, localPort, gatewayAddress, gatewayPort, debug); diff --git a/NXDNIcomNetwork.cpp b/NXDNIcomNetwork.cpp index 730f445..adc4ec6 100644 --- a/NXDNIcomNetwork.cpp +++ b/NXDNIcomNetwork.cpp @@ -28,7 +28,7 @@ const unsigned int BUFFER_LENGTH = 200U; -CNXDNIcomNetwork::CNXDNIcomNetwork(const std::string& localAddress, unsigned int localPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug) : +CNXDNIcomNetwork::CNXDNIcomNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug) : m_socket(localAddress, localPort), m_addr(), m_addrLen(0U), diff --git a/NXDNIcomNetwork.h b/NXDNIcomNetwork.h index 9f74710..f417574 100644 --- a/NXDNIcomNetwork.h +++ b/NXDNIcomNetwork.h @@ -30,7 +30,7 @@ class CNXDNIcomNetwork : public INXDNNetwork { public: - CNXDNIcomNetwork(const std::string& localAddress, unsigned int localPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug); + CNXDNIcomNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); virtual ~CNXDNIcomNetwork(); virtual bool open(); diff --git a/NXDNKenwoodNetwork.cpp b/NXDNKenwoodNetwork.cpp index bed3316..1b7432b 100644 --- a/NXDNKenwoodNetwork.cpp +++ b/NXDNKenwoodNetwork.cpp @@ -33,7 +33,7 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04 const unsigned int BUFFER_LENGTH = 200U; -CNXDNKenwoodNetwork::CNXDNKenwoodNetwork(const std::string& localAddress, unsigned int localPort, const std::string& gwyAddress, unsigned int gwyPort, bool debug) : +CNXDNKenwoodNetwork::CNXDNKenwoodNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gwyAddress, unsigned short gwyPort, bool debug) : m_rtpSocket(localAddress, localPort + 0U), m_rtcpSocket(localAddress, localPort + 1U), m_rtcpAddr(), diff --git a/NXDNKenwoodNetwork.h b/NXDNKenwoodNetwork.h index dc7bf1d..216176e 100644 --- a/NXDNKenwoodNetwork.h +++ b/NXDNKenwoodNetwork.h @@ -29,7 +29,7 @@ class CNXDNKenwoodNetwork : public INXDNNetwork { public: - CNXDNKenwoodNetwork(const std::string& localAddress, unsigned int localPort, const std::string& gwyAddress, unsigned int gwyPort, bool debug); + CNXDNKenwoodNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gwyAddress, unsigned short gwyPort, bool debug); virtual ~CNXDNKenwoodNetwork(); virtual bool open(); diff --git a/P25Network.cpp b/P25Network.cpp index 77a9a7d..2db60d4 100644 --- a/P25Network.cpp +++ b/P25Network.cpp @@ -87,7 +87,7 @@ const unsigned char REC80[] = { const unsigned int BUFFER_LENGTH = 100U; -CP25Network::CP25Network(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool debug) : +CP25Network::CP25Network(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool debug) : m_socket(localPort), m_addr(), m_addrLen(0U), diff --git a/P25Network.h b/P25Network.h index 6b8407c..0724310 100644 --- a/P25Network.h +++ b/P25Network.h @@ -30,7 +30,7 @@ class CP25Network { public: - CP25Network(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool debug); + CP25Network(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool debug); ~CP25Network(); bool open(); diff --git a/POCSAGNetwork.cpp b/POCSAGNetwork.cpp index c0437bd..0fc1322 100644 --- a/POCSAGNetwork.cpp +++ b/POCSAGNetwork.cpp @@ -28,7 +28,7 @@ const unsigned int BUFFER_LENGTH = 200U; -CPOCSAGNetwork::CPOCSAGNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug) : +CPOCSAGNetwork::CPOCSAGNetwork(const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug) : m_socket(myAddress, myPort), m_addr(), m_addrLen(0U), diff --git a/POCSAGNetwork.h b/POCSAGNetwork.h index 693f5ac..b14ae73 100644 --- a/POCSAGNetwork.h +++ b/POCSAGNetwork.h @@ -29,7 +29,7 @@ class CPOCSAGNetwork { public: - CPOCSAGNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gatewayAddress, unsigned int gatewayPort, bool debug); + CPOCSAGNetwork(const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); ~CPOCSAGNetwork(); bool open(); diff --git a/UDPSocket.cpp b/UDPSocket.cpp index 7b819fe..0792863 100644 --- a/UDPSocket.cpp +++ b/UDPSocket.cpp @@ -33,7 +33,7 @@ #define LogInfo(fmt, ...) ::fprintf(stderr, fmt "\n", ## __VA_ARGS__) #endif -CUDPSocket::CUDPSocket(const std::string& address, unsigned int port) : +CUDPSocket::CUDPSocket(const std::string& address, unsigned short port) : m_address_save(address), m_port_save(port), m_counter(0U) @@ -46,7 +46,7 @@ m_counter(0U) } } -CUDPSocket::CUDPSocket(unsigned int port) : +CUDPSocket::CUDPSocket(unsigned short port) : m_address_save(), m_port_save(port), m_counter(0U) @@ -80,7 +80,7 @@ void CUDPSocket::shutdown() #endif } -int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage& addr, unsigned int& address_length) +int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockaddr_storage& addr, unsigned int& address_length) { struct addrinfo hints; ::memset(&hints, 0, sizeof(hints)); @@ -88,7 +88,7 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_ return lookup(hostname, port, addr, address_length, hints); } -int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage& addr, unsigned int& address_length, struct addrinfo& hints) +int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockaddr_storage& addr, unsigned int& address_length, struct addrinfo& hints) { std::string portstr = std::to_string(port); struct addrinfo *res; @@ -171,7 +171,7 @@ bool CUDPSocket::open(unsigned int af) return open(0, af, m_address_save, m_port_save); } -bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned int port) +bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned short port) { sockaddr_storage addr; unsigned int addrlen; @@ -225,7 +225,7 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std return false; } - LogInfo("Opening UDP port on %u", port); + LogInfo("Opening UDP port on %hu", port); } return true; @@ -294,7 +294,7 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag LogError("Error returned from recvfrom, err: %d", errno); if (len == -1 && errno == ENOTSOCK) { - LogMessage("Re-opening UDP port on %u", m_port); + LogMessage("Re-opening UDP port on %hu", m_port[index]); close(); open(); } diff --git a/UDPSocket.h b/UDPSocket.h index 6e3846c..3e75554 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -46,13 +46,13 @@ enum IPMATCHTYPE { class CUDPSocket { public: - CUDPSocket(const std::string& address, unsigned int port = 0U); - CUDPSocket(unsigned int port = 0U); + CUDPSocket(const std::string& address, unsigned short port = 0U); + CUDPSocket(unsigned short port = 0U); ~CUDPSocket(); bool open(unsigned int af = AF_UNSPEC); bool open(const sockaddr_storage& address); - bool open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned int port); + bool open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned short port); int read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &address_length); bool write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int address_length); @@ -63,8 +63,8 @@ public: static void startup(); static void shutdown(); - static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length); - static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints); + static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& address_length); + static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints); static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT); diff --git a/YSFNetwork.cpp b/YSFNetwork.cpp index 3fc5eb6..d611017 100644 --- a/YSFNetwork.cpp +++ b/YSFNetwork.cpp @@ -28,7 +28,7 @@ const unsigned int BUFFER_LENGTH = 200U; -CYSFNetwork::CYSFNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gatewayAddress, unsigned int gatewayPort, const std::string& callsign, bool debug) : +CYSFNetwork::CYSFNetwork(const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& callsign, bool debug) : m_socket(myAddress, myPort), m_addr(), m_addrLen(0U), diff --git a/YSFNetwork.h b/YSFNetwork.h index 3fd7c56..328abd2 100644 --- a/YSFNetwork.h +++ b/YSFNetwork.h @@ -29,7 +29,7 @@ class CYSFNetwork { public: - CYSFNetwork(const std::string& myAddress, unsigned int myPort, const std::string& gatewayAddress, unsigned int gatewayPort, const std::string& callsign, bool debug); + CYSFNetwork(const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& callsign, bool debug); ~CYSFNetwork(); bool open(); From 7008c624d9cc40197106c9b9e24fdbb188fd339d Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 25 Apr 2021 11:10:35 +0100 Subject: [PATCH 3/3] Regularise the local address handling across all of the protocol. --- Conf.cpp | 86 +++++++++++++++++++++++++++++++------------ Conf.h | 30 ++++++++++----- DMRDirectNetwork.cpp | 4 +- DMRDirectNetwork.h | 2 +- DMRGatewayNetwork.cpp | 4 +- DMRGatewayNetwork.h | 2 +- DStarNetwork.cpp | 4 +- DStarNetwork.h | 4 +- FMNetwork.h | 2 +- M17Network.cpp | 8 ++-- M17Network.h | 2 +- MMDVM.ini | 17 ++++++--- MMDVMHost.cpp | 55 +++++++++++++++------------ P25Network.cpp | 6 +-- P25Network.h | 4 +- POCSAGNetwork.cpp | 6 +-- POCSAGNetwork.h | 4 +- UDPController.cpp | 4 +- UDPController.h | 2 +- Version.h | 2 +- YSFNetwork.cpp | 4 +- YSFNetwork.h | 2 +- 22 files changed, 158 insertions(+), 96 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 6c5c01c..4870a03 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -100,6 +100,7 @@ m_modemI2CPort(), m_modemI2CAddress(0x22U), m_modemModemAddress(), m_modemModemPort(0U), +m_modemLocalAddress(), m_modemLocalPort(0U), m_modemRXInvert(false), m_modemTXInvert(false), @@ -233,14 +234,16 @@ m_ax25Trace(false), m_dstarNetworkEnabled(false), m_dstarGatewayAddress(), m_dstarGatewayPort(0U), +m_dstarLocalAddress(), m_dstarLocalPort(0U), m_dstarNetworkModeHang(3U), m_dstarNetworkDebug(false), m_dmrNetworkEnabled(false), m_dmrNetworkType("Gateway"), -m_dmrNetworkAddress(), -m_dmrNetworkPort(0U), -m_dmrNetworkLocal(0U), +m_dmrNetworkRemoteAddress(), +m_dmrNetworkRemotePort(0U), +m_dmrNetworkLocalAddress(), +m_dmrNetworkLocalPort(0U), m_dmrNetworkPassword(), m_dmrNetworkOptions(), m_dmrNetworkDebug(false), @@ -249,8 +252,8 @@ m_dmrNetworkSlot1(true), m_dmrNetworkSlot2(true), m_dmrNetworkModeHang(3U), m_fusionNetworkEnabled(false), -m_fusionNetworkMyAddress(), -m_fusionNetworkMyPort(0U), +m_fusionNetworkLocalAddress(), +m_fusionNetworkLocalPort(0U), m_fusionNetworkGatewayAddress(), m_fusionNetworkGatewayPort(0U), m_fusionNetworkModeHang(3U), @@ -258,6 +261,7 @@ m_fusionNetworkDebug(false), m_p25NetworkEnabled(false), m_p25GatewayAddress(), m_p25GatewayPort(0U), +m_p25LocalAddress(), m_p25LocalPort(0U), m_p25NetworkModeHang(3U), m_p25NetworkDebug(false), @@ -272,6 +276,7 @@ m_nxdnNetworkDebug(false), m_m17NetworkEnabled(false), m_m17GatewayAddress(), m_m17GatewayPort(0U), +m_m17LocalAddress(), m_m17LocalPort(0U), m_m17NetworkModeHang(3U), m_m17NetworkDebug(false), @@ -536,6 +541,8 @@ bool CConf::read() m_modemModemAddress = value; else if (::strcmp(key, "ModemPort") == 0) m_modemModemPort = (unsigned short)::atoi(value); + else if (::strcmp(key, "LocalAddress") == 0) + m_modemLocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) m_modemLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "RXInvert") == 0) @@ -897,6 +904,8 @@ bool CConf::read() m_dstarGatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) m_dstarGatewayPort = (unsigned short)::atoi(value); + else if (::strcmp(key, "LocalAddress") == 0) + m_dstarLocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) m_dstarLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) @@ -908,12 +917,14 @@ bool CConf::read() m_dmrNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Type") == 0) m_dmrNetworkType = value; - else if (::strcmp(key, "Address") == 0) - m_dmrNetworkAddress = value; - else if (::strcmp(key, "Port") == 0) - m_dmrNetworkPort = (unsigned short)::atoi(value); - else if (::strcmp(key, "Local") == 0) - m_dmrNetworkLocal = (unsigned short)::atoi(value); + else if (::strcmp(key, "RemoteAddress") == 0) + m_dmrNetworkRemoteAddress = value; + else if (::strcmp(key, "RemotePort") == 0) + m_dmrNetworkRemotePort = (unsigned short)::atoi(value); + else if (::strcmp(key, "LocalAddress") == 0) + m_dmrNetworkLocalAddress = value; + else if (::strcmp(key, "LocalPort") == 0) + m_dmrNetworkLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "Password") == 0) m_dmrNetworkPassword = value; else if (::strcmp(key, "Options") == 0) @@ -932,9 +943,9 @@ bool CConf::read() if (::strcmp(key, "Enable") == 0) m_fusionNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "LocalAddress") == 0) - m_fusionNetworkMyAddress = value; + m_fusionNetworkLocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) - m_fusionNetworkMyPort = (unsigned short)::atoi(value); + m_fusionNetworkLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "GatewayAddress") == 0) m_fusionNetworkGatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) @@ -950,6 +961,8 @@ bool CConf::read() m_p25GatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) m_p25GatewayPort = (unsigned short)::atoi(value); + else if (::strcmp(key, "LocalAddress") == 0) + m_p25LocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) m_p25LocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) @@ -974,6 +987,8 @@ bool CConf::read() } else if (section == SECTION_M17_NETWORK) { if (::strcmp(key, "Enable") == 0) m_m17NetworkEnabled = ::atoi(value) == 1; + else if (::strcmp(key, "LocalAddress") == 0) + m_m17LocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) m_m17LocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "GatewayAddress") == 0) @@ -1294,6 +1309,11 @@ unsigned short CConf::getModemModemPort() const return m_modemModemPort; } +std::string CConf::getModemLocalAddress() const +{ + return m_modemLocalAddress; +} + unsigned short CConf::getModemLocalPort() const { return m_modemLocalPort; @@ -1959,6 +1979,11 @@ unsigned short CConf::getDStarGatewayPort() const return m_dstarGatewayPort; } +std::string CConf::getDStarLocalAddress() const +{ + return m_dstarLocalAddress; +} + unsigned short CConf::getDStarLocalPort() const { return m_dstarLocalPort; @@ -1984,19 +2009,24 @@ std::string CConf::getDMRNetworkType() const return m_dmrNetworkType; } -std::string CConf::getDMRNetworkAddress() const +std::string CConf::getDMRNetworkRemoteAddress() const { - return m_dmrNetworkAddress; + return m_dmrNetworkRemoteAddress; } -unsigned short CConf::getDMRNetworkPort() const +unsigned short CConf::getDMRNetworkRemotePort() const { - return m_dmrNetworkPort; + return m_dmrNetworkRemotePort; } -unsigned short CConf::getDMRNetworkLocal() const +std::string CConf::getDMRNetworkLocalAddress() const { - return m_dmrNetworkLocal; + return m_dmrNetworkLocalAddress; +} + +unsigned short CConf::getDMRNetworkLocalPort() const +{ + return m_dmrNetworkLocalPort; } std::string CConf::getDMRNetworkPassword() const @@ -2039,14 +2069,14 @@ bool CConf::getFusionNetworkEnabled() const return m_fusionNetworkEnabled; } -std::string CConf::getFusionNetworkMyAddress() const +std::string CConf::getFusionNetworkLocalAddress() const { - return m_fusionNetworkMyAddress; + return m_fusionNetworkLocalAddress; } -unsigned short CConf::getFusionNetworkMyPort() const +unsigned short CConf::getFusionNetworkLocalPort() const { - return m_fusionNetworkMyPort; + return m_fusionNetworkLocalPort; } std::string CConf::getFusionNetworkGatewayAddress() const @@ -2084,6 +2114,11 @@ unsigned short CConf::getP25GatewayPort() const return m_p25GatewayPort; } +std::string CConf::getP25LocalAddress() const +{ + return m_p25LocalAddress; +} + unsigned short CConf::getP25LocalPort() const { return m_p25LocalPort; @@ -2154,6 +2189,11 @@ unsigned short CConf::getM17GatewayPort() const return m_m17GatewayPort; } +std::string CConf::getM17LocalAddress() const +{ + return m_m17LocalAddress; +} + unsigned short CConf::getM17LocalPort() const { return m_m17LocalPort; diff --git a/Conf.h b/Conf.h index 5140a5b..3fde503 100644 --- a/Conf.h +++ b/Conf.h @@ -77,6 +77,7 @@ public: unsigned int getModemI2CAddress() const; std::string getModemModemAddress() const; unsigned short getModemModemPort() const; + std::string getModemLocalAddress() const; unsigned short getModemLocalPort() const; bool getModemRXInvert() const; bool getModemTXInvert() const; @@ -232,6 +233,7 @@ public: bool getDStarNetworkEnabled() const; std::string getDStarGatewayAddress() const; unsigned short getDStarGatewayPort() const; + std::string getDStarLocalAddress() const; unsigned short getDStarLocalPort() const; unsigned int getDStarNetworkModeHang() const; bool getDStarNetworkDebug() const; @@ -239,9 +241,10 @@ public: // The DMR Network section bool getDMRNetworkEnabled() const; std::string getDMRNetworkType() const; - std::string getDMRNetworkAddress() const; - unsigned short getDMRNetworkPort() const; - unsigned short getDMRNetworkLocal() const; + std::string getDMRNetworkRemoteAddress() const; + unsigned short getDMRNetworkRemotePort() const; + std::string getDMRNetworkLocalAddress() const; + unsigned short getDMRNetworkLocalPort() const; std::string getDMRNetworkPassword() const; std::string getDMRNetworkOptions() const; bool getDMRNetworkDebug() const; @@ -252,8 +255,8 @@ public: // The System Fusion Network section bool getFusionNetworkEnabled() const; - std::string getFusionNetworkMyAddress() const; - unsigned short getFusionNetworkMyPort() const; + std::string getFusionNetworkLocalAddress() const; + unsigned short getFusionNetworkLocalPort() const; std::string getFusionNetworkGatewayAddress() const; unsigned short getFusionNetworkGatewayPort() const; unsigned int getFusionNetworkModeHang() const; @@ -263,6 +266,7 @@ public: bool getP25NetworkEnabled() const; std::string getP25GatewayAddress() const; unsigned short getP25GatewayPort() const; + std::string getP25LocalAddress() const; unsigned short getP25LocalPort() const; unsigned int getP25NetworkModeHang() const; bool getP25NetworkDebug() const; @@ -281,6 +285,7 @@ public: bool getM17NetworkEnabled() const; std::string getM17GatewayAddress() const; unsigned short getM17GatewayPort() const; + std::string getM17LocalAddress() const; unsigned short getM17LocalPort() const; unsigned int getM17NetworkModeHang() const; bool getM17NetworkDebug() const; @@ -406,6 +411,7 @@ private: unsigned int m_modemI2CAddress; std::string m_modemModemAddress; unsigned short m_modemModemPort; + std::string m_modemLocalAddress; unsigned short m_modemLocalPort; bool m_modemRXInvert; bool m_modemTXInvert; @@ -550,15 +556,17 @@ private: bool m_dstarNetworkEnabled; std::string m_dstarGatewayAddress; unsigned short m_dstarGatewayPort; + std::string m_dstarLocalAddress; unsigned short m_dstarLocalPort; unsigned int m_dstarNetworkModeHang; bool m_dstarNetworkDebug; bool m_dmrNetworkEnabled; std::string m_dmrNetworkType; - std::string m_dmrNetworkAddress; - unsigned short m_dmrNetworkPort; - unsigned short m_dmrNetworkLocal; + std::string m_dmrNetworkRemoteAddress; + unsigned short m_dmrNetworkRemotePort; + std::string m_dmrNetworkLocalAddress; + unsigned short m_dmrNetworkLocalPort; std::string m_dmrNetworkPassword; std::string m_dmrNetworkOptions; bool m_dmrNetworkDebug; @@ -568,8 +576,8 @@ private: unsigned int m_dmrNetworkModeHang; bool m_fusionNetworkEnabled; - std::string m_fusionNetworkMyAddress; - unsigned short m_fusionNetworkMyPort; + std::string m_fusionNetworkLocalAddress; + unsigned short m_fusionNetworkLocalPort; std::string m_fusionNetworkGatewayAddress; unsigned short m_fusionNetworkGatewayPort; unsigned int m_fusionNetworkModeHang; @@ -578,6 +586,7 @@ private: bool m_p25NetworkEnabled; std::string m_p25GatewayAddress; unsigned short m_p25GatewayPort; + std::string m_p25LocalAddress; unsigned short m_p25LocalPort; unsigned int m_p25NetworkModeHang; bool m_p25NetworkDebug; @@ -594,6 +603,7 @@ private: bool m_m17NetworkEnabled; std::string m_m17GatewayAddress; unsigned short m_m17GatewayPort; + std::string m_m17LocalAddress; unsigned short m_m17LocalPort; unsigned int m_m17NetworkModeHang; bool m_m17NetworkDebug; diff --git a/DMRDirectNetwork.cpp b/DMRDirectNetwork.cpp index 04886c1..ba36a69 100644 --- a/DMRDirectNetwork.cpp +++ b/DMRDirectNetwork.cpp @@ -30,7 +30,7 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; -CDMRDirectNetwork::CDMRDirectNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) : +CDMRDirectNetwork::CDMRDirectNetwork(const std::string& address, unsigned short port, const std::string& localAddress, unsigned short localPort, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) : m_address(address), m_port(port), m_addr(), @@ -40,7 +40,7 @@ m_password(password), m_duplex(duplex), m_version(version), m_debug(debug), -m_socket(local), +m_socket(localAddress, localPort), m_enabled(false), m_slot1(slot1), m_slot2(slot2), diff --git a/DMRDirectNetwork.h b/DMRDirectNetwork.h index 6ebff40..5d6a959 100644 --- a/DMRDirectNetwork.h +++ b/DMRDirectNetwork.h @@ -32,7 +32,7 @@ class CDMRDirectNetwork : public IDMRNetwork { public: - CDMRDirectNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug); + CDMRDirectNetwork(const std::string& remoteAddress, unsigned short remotePort, const std::string& localAddress, unsigned short localPort, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug); virtual ~CDMRDirectNetwork(); virtual void setOptions(const std::string& options); diff --git a/DMRGatewayNetwork.cpp b/DMRGatewayNetwork.cpp index fe4cda8..5dd55b5 100644 --- a/DMRGatewayNetwork.cpp +++ b/DMRGatewayNetwork.cpp @@ -31,7 +31,7 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; -CDMRGatewayNetwork::CDMRGatewayNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) : +CDMRGatewayNetwork::CDMRGatewayNetwork(const std::string& address, unsigned short port, const std::string& localAddress, unsigned short localPort, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) : m_addressStr(address), m_addr(), m_addrLen(0U), @@ -40,7 +40,7 @@ m_id(NULL), m_duplex(duplex), m_version(version), m_debug(debug), -m_socket(local), +m_socket(localAddress, localPort), m_enabled(false), m_slot1(slot1), m_slot2(slot2), diff --git a/DMRGatewayNetwork.h b/DMRGatewayNetwork.h index 5979a3a..160dc51 100644 --- a/DMRGatewayNetwork.h +++ b/DMRGatewayNetwork.h @@ -33,7 +33,7 @@ class CDMRGatewayNetwork : public IDMRNetwork { public: - CDMRGatewayNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug); + CDMRGatewayNetwork(const std::string& remoteAddress, unsigned short remotePort, const std::string& localAddress, unsigned short localPort, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug); virtual ~CDMRGatewayNetwork(); virtual void setOptions(const std::string& options); diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index 96c826b..7f9e9dd 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -30,8 +30,8 @@ const unsigned int BUFFER_LENGTH = 100U; -CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool duplex, const char* version, bool debug) : -m_socket(localPort), +CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& localAddress, unsigned short localPort, bool duplex, const char* version, bool debug) : +m_socket(localAddress, localPort), m_addr(), m_addrLen(0U), m_duplex(duplex), diff --git a/DStarNetwork.h b/DStarNetwork.h index 8ecd5ac..d7a1cc4 100644 --- a/DStarNetwork.h +++ b/DStarNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2020,2021 by Jonathan Naylor G4KLX * * 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 @@ -30,7 +30,7 @@ class CDStarNetwork { public: - CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool duplex, const char* version, bool debug); + CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& localAddress, unsigned short localPort, bool duplex, const char* version, bool debug); ~CDStarNetwork(); bool open(); diff --git a/FMNetwork.h b/FMNetwork.h index dd2a8e6..606bad6 100644 --- a/FMNetwork.h +++ b/FMNetwork.h @@ -31,7 +31,7 @@ enum FM_NETWORK_PROTOCOL { class CFMNetwork { public: - CFMNetwork(const std::string& callsign, const std::string& protocol, const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); + CFMNetwork(const std::string& callsign, const std::string& protocol, const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); ~CFMNetwork(); bool open(); diff --git a/M17Network.cpp b/M17Network.cpp index 3578252..9a3bf8d 100644 --- a/M17Network.cpp +++ b/M17Network.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 by Jonathan Naylor G4KLX + * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX * * 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 @@ -29,8 +29,8 @@ const unsigned int BUFFER_LENGTH = 200U; -CM17Network::CM17Network(unsigned short localPort, const std::string& gwyAddress, unsigned short gwyPort, bool debug) : -m_socket(localPort), +CM17Network::CM17Network(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug) : +m_socket(localAddress, localPort), m_addr(), m_addrLen(0U), m_debug(debug), @@ -41,7 +41,7 @@ m_buffer(1000U, "M17 Network"), m_random(), m_timer(1000U, 5U) { - if (CUDPSocket::lookup(gwyAddress, gwyPort, m_addr, m_addrLen) != 0) { + if (CUDPSocket::lookup(gatewayAddress, gatewayPort, m_addr, m_addrLen) != 0) { m_addrLen = 0U; return; } diff --git a/M17Network.h b/M17Network.h index 6b002e0..dbc2b2c 100644 --- a/M17Network.h +++ b/M17Network.h @@ -29,7 +29,7 @@ class CM17Network { public: - CM17Network(unsigned short localPort, const std::string& gwyAddress, unsigned short gwyPort, bool debug); + CM17Network(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); ~CM17Network(); bool open(); diff --git a/MMDVM.ini b/MMDVM.ini index 7a8aa4c..2880c65 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -56,6 +56,7 @@ I2CAddress=0x22 # IP parameters for UDP connection ModemAddress=192.168.2.100 ModemPort=3334 +LocalAddress=192.168.2.1 LocalPort=3335 TXInvert=1 @@ -207,9 +208,10 @@ Trace=1 [D-Star Network] Enable=1 +LocalAddress=127.0.0.1 +LocalPort=20011 GatewayAddress=127.0.0.1 GatewayPort=20010 -LocalPort=20011 # ModeHang=3 Debug=0 @@ -218,9 +220,10 @@ Enable=1 # Type may be either 'Direct' or 'Gateway'. When Direct you must provide the Master's # address as well as the Password, and for DMR+, Options also. Type=Gateway -Address=127.0.0.1 -Port=62031 -Local=62032 +LocalAddress=127.0.0.1 +LocalPort=62032 +RemoteAddress=127.0.0.1 +RemotePort=62031 # Password=P@ssw0rd1234 Jitter=360 Slot1=1 @@ -240,9 +243,10 @@ Debug=0 [P25 Network] Enable=1 +LocalAddress=127.0.0.1 +LocalPort=32010 GatewayAddress=127.0.0.1 GatewayPort=42020 -LocalPort=32010 # ModeHang=3 Debug=0 @@ -258,9 +262,10 @@ Debug=0 [M17 Network] Enable=1 +LocalAddress=127.0.0.1 +LocalPort=17011 GatewayAddress=127.0.0.1 GatewayPort=17010 -LocalPort=17011 # ModeHang=3 Debug=0 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 0edb12a..58b678b 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1330,8 +1330,9 @@ bool CMMDVMHost::createModem() std::string i2cPort = m_conf.getModemI2CPort(); unsigned int i2cAddress = m_conf.getModemI2CAddress(); std::string modemAddress = m_conf.getModemModemAddress(); - unsigned int modemPort = m_conf.getModemModemPort(); - unsigned int localPort = m_conf.getModemLocalPort(); + unsigned short modemPort = m_conf.getModemModemPort(); + std::string localAddress = m_conf.getModemLocalAddress(); + unsigned short localPort = m_conf.getModemLocalPort(); bool rxInvert = m_conf.getModemRXInvert(); bool txInvert = m_conf.getModemTXInvert(); bool pttInvert = m_conf.getModemPTTInvert(); @@ -1378,8 +1379,9 @@ bool CMMDVMHost::createModem() LogInfo(" UART Speed: %u", uartSpeed); } else if (protocol == "udp") { LogInfo(" Modem Address: %s", modemAddress.c_str()); - LogInfo(" Modem Port: %u", modemPort); - LogInfo(" Local Port: %u", localPort); + LogInfo(" Modem Port: %hu", modemPort); + LogInfo(" Local Address: %s", localAddress.c_str()); + LogInfo(" Local Port: %hu", localPort); } #if defined(__linux__) else if (protocol == "i2c") { @@ -1418,7 +1420,7 @@ bool CMMDVMHost::createModem() if (protocol == "uart") port = new CUARTController(uartPort, uartSpeed, true); else if (protocol == "udp") - port = new CUDPController(modemAddress, modemPort, localPort); + port = new CUDPController(modemAddress, modemPort, localAddress, localPort); #if defined(__linux__) else if (protocol == "i2c") port = new CI2CController(i2cPort, i2cAddress); @@ -1540,6 +1542,7 @@ bool CMMDVMHost::createDStarNetwork() { std::string gatewayAddress = m_conf.getDStarGatewayAddress(); unsigned short gatewayPort = m_conf.getDStarGatewayPort(); + std::string localAddress = m_conf.getDStarLocalAddress(); unsigned short localPort = m_conf.getDStarLocalPort(); bool debug = m_conf.getDStarNetworkDebug(); m_dstarNetModeHang = m_conf.getDStarNetworkModeHang(); @@ -1547,10 +1550,11 @@ bool CMMDVMHost::createDStarNetwork() LogInfo("D-Star Network Parameters"); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); LogInfo(" Gateway Port: %hu", gatewayPort); + LogInfo(" Local Address: %s", localAddress.c_str()); LogInfo(" Local Port: %hu", localPort); LogInfo(" Mode Hang: %us", m_dstarNetModeHang); - m_dstarNetwork = new CDStarNetwork(gatewayAddress, gatewayPort, localPort, m_duplex, VERSION, debug); + m_dstarNetwork = new CDStarNetwork(gatewayAddress, gatewayPort, localAddress, localPort, m_duplex, VERSION, debug); bool ret = m_dstarNetwork->open(); if (!ret) { @@ -1566,9 +1570,10 @@ bool CMMDVMHost::createDStarNetwork() bool CMMDVMHost::createDMRNetwork() { - std::string address = m_conf.getDMRNetworkAddress(); - unsigned short port = m_conf.getDMRNetworkPort(); - unsigned short local = m_conf.getDMRNetworkLocal(); + std::string remoteAddress = m_conf.getDMRNetworkRemoteAddress(); + unsigned short remotePort = m_conf.getDMRNetworkRemotePort(); + std::string localAddress = m_conf.getDMRNetworkLocalAddress(); + unsigned short localPort = m_conf.getDMRNetworkLocalPort(); unsigned int id = m_conf.getDMRId(); std::string password = m_conf.getDMRNetworkPassword(); bool debug = m_conf.getDMRNetworkDebug(); @@ -1583,21 +1588,19 @@ bool CMMDVMHost::createDMRNetwork() LogInfo("DMR Network Parameters"); LogInfo(" Type: %s", type.c_str()); - LogInfo(" Address: %s", address.c_str()); - LogInfo(" Port: %hu", port); - if (local > 0U) - LogInfo(" Local: %hu", local); - else - LogInfo(" Local: random"); + LogInfo(" Remote Address: %s", remoteAddress.c_str()); + LogInfo(" Remote Port: %hu", remotePort); + LogInfo(" Local Address: %s", localAddress.c_str()); + LogInfo(" Local Port: %hu", localPort); LogInfo(" Jitter: %ums", jitter); LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled"); LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled"); LogInfo(" Mode Hang: %us", m_dmrNetModeHang); if (type == "Direct") - m_dmrNetwork = new CDMRDirectNetwork(address, port, local, id, password, m_duplex, VERSION, slot1, slot2, hwType, debug); + m_dmrNetwork = new CDMRDirectNetwork(remoteAddress, remotePort, localAddress, localPort, id, password, m_duplex, VERSION, slot1, slot2, hwType, debug); else - m_dmrNetwork = new CDMRGatewayNetwork(address, port, local, id, m_duplex, VERSION, slot1, slot2, hwType, debug); + m_dmrNetwork = new CDMRGatewayNetwork(remoteAddress, remotePort, localAddress, localPort, id, m_duplex, VERSION, slot1, slot2, hwType, debug); unsigned int rxFrequency = m_conf.getRXFrequency(); unsigned int txFrequency = m_conf.getTXFrequency(); @@ -1650,21 +1653,21 @@ bool CMMDVMHost::createDMRNetwork() bool CMMDVMHost::createYSFNetwork() { - std::string myAddress = m_conf.getFusionNetworkMyAddress(); - unsigned short myPort = m_conf.getFusionNetworkMyPort(); + std::string localAddress = m_conf.getFusionNetworkLocalAddress(); + unsigned short localPort = m_conf.getFusionNetworkLocalPort(); std::string gatewayAddress = m_conf.getFusionNetworkGatewayAddress(); unsigned short gatewayPort = m_conf.getFusionNetworkGatewayPort(); m_ysfNetModeHang = m_conf.getFusionNetworkModeHang(); bool debug = m_conf.getFusionNetworkDebug(); LogInfo("System Fusion Network Parameters"); - LogInfo(" Local Address: %s", myAddress.c_str()); - LogInfo(" Local Port: %hu", myPort); + LogInfo(" Local Address: %s", localAddress.c_str()); + LogInfo(" Local Port: %hu", localPort); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); LogInfo(" Gateway Port: %hu", gatewayPort); LogInfo(" Mode Hang: %us", m_ysfNetModeHang); - m_ysfNetwork = new CYSFNetwork(myAddress, myPort, gatewayAddress, gatewayPort, m_callsign, debug); + m_ysfNetwork = new CYSFNetwork(localAddress, localPort, gatewayAddress, gatewayPort, m_callsign, debug); bool ret = m_ysfNetwork->open(); if (!ret) { @@ -1682,6 +1685,7 @@ bool CMMDVMHost::createP25Network() { std::string gatewayAddress = m_conf.getP25GatewayAddress(); unsigned short gatewayPort = m_conf.getP25GatewayPort(); + std::string localAddress = m_conf.getP25LocalAddress(); unsigned short localPort = m_conf.getP25LocalPort(); m_p25NetModeHang = m_conf.getP25NetworkModeHang(); bool debug = m_conf.getP25NetworkDebug(); @@ -1689,10 +1693,11 @@ bool CMMDVMHost::createP25Network() LogInfo("P25 Network Parameters"); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); LogInfo(" Gateway Port: %hu", gatewayPort); + LogInfo(" Local Address: %s", localAddress.c_str()); LogInfo(" Local Port: %hu", localPort); LogInfo(" Mode Hang: %us", m_p25NetModeHang); - m_p25Network = new CP25Network(gatewayAddress, gatewayPort, localPort, debug); + m_p25Network = new CP25Network(gatewayAddress, gatewayPort, localAddress, localPort, debug); bool ret = m_p25Network->open(); if (!ret) { @@ -1745,6 +1750,7 @@ bool CMMDVMHost::createM17Network() { std::string gatewayAddress = m_conf.getM17GatewayAddress(); unsigned short gatewayPort = m_conf.getM17GatewayPort(); + std::string localAddress = m_conf.getM17LocalAddress(); unsigned short localPort = m_conf.getM17LocalPort(); m_m17NetModeHang = m_conf.getM17NetworkModeHang(); bool debug = m_conf.getM17NetworkDebug(); @@ -1752,10 +1758,11 @@ bool CMMDVMHost::createM17Network() LogInfo("M17 Network Parameters"); LogInfo(" Gateway Address: %s", gatewayAddress.c_str()); LogInfo(" Gateway Port: %hu", gatewayPort); + LogInfo(" Local Address: %s", localAddress.c_str()); LogInfo(" Local Port: %hu", localPort); LogInfo(" Mode Hang: %us", m_m17NetModeHang); - m_m17Network = new CM17Network(localPort, gatewayAddress, gatewayPort, debug); + m_m17Network = new CM17Network(localAddress, localPort, gatewayAddress, gatewayPort, debug); bool ret = m_m17Network->open(); if (!ret) { delete m_m17Network; diff --git a/P25Network.cpp b/P25Network.cpp index 2db60d4..b63b522 100644 --- a/P25Network.cpp +++ b/P25Network.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2019,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2019,2020,2021 by Jonathan Naylor G4KLX * * 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 @@ -87,8 +87,8 @@ const unsigned char REC80[] = { const unsigned int BUFFER_LENGTH = 100U; -CP25Network::CP25Network(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool debug) : -m_socket(localPort), +CP25Network::CP25Network(const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& localAddress, unsigned short localPort, bool debug) : +m_socket(localAddress, localPort), m_addr(), m_addrLen(0U), m_debug(debug), diff --git a/P25Network.h b/P25Network.h index 0724310..7023c94 100644 --- a/P25Network.h +++ b/P25Network.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2020,2021 by Jonathan Naylor G4KLX * * 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 @@ -30,7 +30,7 @@ class CP25Network { public: - CP25Network(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool debug); + CP25Network(const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& localAddress, unsigned short localPort, bool debug); ~CP25Network(); bool open(); diff --git a/POCSAGNetwork.cpp b/POCSAGNetwork.cpp index 0fc1322..2a4e650 100644 --- a/POCSAGNetwork.cpp +++ b/POCSAGNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018,2019,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2019,2020,2021 by Jonathan Naylor G4KLX * * 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 @@ -28,8 +28,8 @@ const unsigned int BUFFER_LENGTH = 200U; -CPOCSAGNetwork::CPOCSAGNetwork(const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug) : -m_socket(myAddress, myPort), +CPOCSAGNetwork::CPOCSAGNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug) : +m_socket(localAddress, localPort), m_addr(), m_addrLen(0U), m_debug(debug), diff --git a/POCSAGNetwork.h b/POCSAGNetwork.h index b14ae73..beceb9b 100644 --- a/POCSAGNetwork.h +++ b/POCSAGNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2020,2021 by Jonathan Naylor G4KLX * * 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 @@ -29,7 +29,7 @@ class CPOCSAGNetwork { public: - CPOCSAGNetwork(const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); + CPOCSAGNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); ~CPOCSAGNetwork(); bool open(); diff --git a/UDPController.cpp b/UDPController.cpp index 827446f..3996d32 100644 --- a/UDPController.cpp +++ b/UDPController.cpp @@ -24,8 +24,8 @@ const unsigned int BUFFER_LENGTH = 600U; -CUDPController::CUDPController(const std::string& modemAddress, unsigned int modemPort, unsigned int localPort) : -m_socket(localPort), +CUDPController::CUDPController(const std::string& modemAddress, unsigned int modemPort, const std::string& localAddress, unsigned int localPort) : +m_socket(localAddress, localPort), m_addr(), m_addrLen(0U), m_buffer(2000U, "UDP Controller Ring Buffer") diff --git a/UDPController.h b/UDPController.h index ee10cb3..85ee612 100644 --- a/UDPController.h +++ b/UDPController.h @@ -27,7 +27,7 @@ class CUDPController : public IModemPort { public: - CUDPController(const std::string& modemAddress, unsigned int modemPort, unsigned int localPort); + CUDPController(const std::string& modemAddress, unsigned int modemPort, const std::string& localAddress, unsigned int localPort); virtual ~CUDPController(); virtual bool open(); diff --git a/Version.h b/Version.h index b9a0ca6..69f184a 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20210424"; +const char* VERSION = "20210425"; #endif diff --git a/YSFNetwork.cpp b/YSFNetwork.cpp index b9bd0d2..727a1a0 100644 --- a/YSFNetwork.cpp +++ b/YSFNetwork.cpp @@ -28,8 +28,8 @@ const unsigned int BUFFER_LENGTH = 200U; -CYSFNetwork::CYSFNetwork(const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& callsign, bool debug) : -m_socket(myAddress, myPort), +CYSFNetwork::CYSFNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& callsign, bool debug) : +m_socket(localAddress, localPort), m_addr(), m_addrLen(0U), m_callsign(), diff --git a/YSFNetwork.h b/YSFNetwork.h index ecc3a91..918134b 100644 --- a/YSFNetwork.h +++ b/YSFNetwork.h @@ -29,7 +29,7 @@ class CYSFNetwork { public: - CYSFNetwork(const std::string& myAddress, unsigned short myPort, const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& callsign, bool debug); + CYSFNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& callsign, bool debug); ~CYSFNetwork(); bool open();