diff --git a/Conf.cpp b/Conf.cpp index 788da15..b0273d9 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,9 +541,11 @@ bool CConf::read() else if (::strcmp(key, "ModemAddress") == 0) m_modemModemAddress = value; else if (::strcmp(key, "ModemPort") == 0) - m_modemModemPort = (unsigned int)::atoi(value); + m_modemModemPort = (unsigned short)::atoi(value); + else if (::strcmp(key, "LocalAddress") == 0) + m_modemLocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) - m_modemLocalPort = (unsigned int)::atoi(value); + m_modemLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "RXInvert") == 0) m_modemRXInvert = ::atoi(value) == 1; else if (::strcmp(key, "TXInvert") == 0) @@ -595,9 +602,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_DSTAR) { @@ -897,9 +904,11 @@ 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, "LocalAddress") == 0) + m_dstarLocalAddress = 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) @@ -909,12 +918,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 int)::atoi(value); - else if (::strcmp(key, "Local") == 0) - m_dmrNetworkLocal = (unsigned int)::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) @@ -933,13 +944,13 @@ 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 int)::atoi(value); + m_fusionNetworkLocalPort = (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) @@ -950,9 +961,11 @@ 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, "LocalAddress") == 0) + m_p25LocalAddress = 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) @@ -963,11 +976,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) @@ -975,12 +988,14 @@ 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 int)::atoi(value); + m_m17LocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "GatewayAddress") == 0) m_m17GatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) - m_m17GatewayPort = (unsigned int)::atoi(value); + m_m17GatewayPort = (unsigned short)::atoi(value); else if (::strcmp(key, "ModeHang") == 0) m_m17NetworkModeHang = (unsigned int)::atoi(value); else if (::strcmp(key, "Debug") == 0) @@ -991,11 +1006,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) @@ -1008,11 +1023,11 @@ bool CConf::read() else if (::strcmp(key, "LocalAddress") == 0) m_fmLocalAddress = value; else if (::strcmp(key, "LocalPort") == 0) - m_fmLocalPort = (unsigned int)::atoi(value); + m_fmLocalPort = (unsigned short)::atoi(value); else if (::strcmp(key, "GatewayAddress") == 0) m_fmGatewayAddress = value; else if (::strcmp(key, "GatewayPort") == 0) - m_fmGatewayPort = (unsigned int)::atoi(value); + m_fmGatewayPort = (unsigned short)::atoi(value); else if (::strcmp(key, "PreEmphasis") == 0) m_fmPreEmphasis = ::atoi(value) == 1; else if (::strcmp(key, "DeEmphasis") == 0) @@ -1100,9 +1115,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) @@ -1118,7 +1133,7 @@ bool CConf::read() if (::strcmp(key, "Enable") == 0) m_remoteControlEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Port") == 0) - m_remoteControlPort = (unsigned int)::atoi(value); + m_remoteControlPort = (unsigned short)::atoi(value); } } @@ -1292,12 +1307,17 @@ std::string CConf::getModemModemAddress() const return m_modemModemAddress; } -unsigned int CConf::getModemModemPort() const +unsigned short CConf::getModemModemPort() const { return m_modemModemPort; } -unsigned int CConf::getModemLocalPort() const +std::string CConf::getModemLocalAddress() const +{ + return m_modemLocalAddress; +} + +unsigned short CConf::getModemLocalPort() const { return m_modemLocalPort; } @@ -1437,12 +1457,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; } @@ -1957,12 +1977,17 @@ 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 +std::string CConf::getDStarLocalAddress() const +{ + return m_dstarLocalAddress; +} + +unsigned short CConf::getDStarLocalPort() const { return m_dstarLocalPort; } @@ -1987,19 +2012,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 int CConf::getDMRNetworkPort() const +unsigned short CConf::getDMRNetworkRemotePort() const { - return m_dmrNetworkPort; + return m_dmrNetworkRemotePort; } -unsigned int 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 @@ -2042,14 +2072,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 int CConf::getFusionNetworkMyPort() const +unsigned short CConf::getFusionNetworkLocalPort() const { - return m_fusionNetworkMyPort; + return m_fusionNetworkLocalPort; } std::string CConf::getFusionNetworkGatewayAddress() const @@ -2057,7 +2087,7 @@ std::string CConf::getFusionNetworkGatewayAddress() const return m_fusionNetworkGatewayAddress; } -unsigned int CConf::getFusionNetworkGatewayPort() const +unsigned short CConf::getFusionNetworkGatewayPort() const { return m_fusionNetworkGatewayPort; } @@ -2082,12 +2112,17 @@ 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 +std::string CConf::getP25LocalAddress() const +{ + return m_p25LocalAddress; +} + +unsigned short CConf::getP25LocalPort() const { return m_p25LocalPort; } @@ -2117,7 +2152,7 @@ std::string CConf::getNXDNGatewayAddress() const return m_nxdnGatewayAddress; } -unsigned int CConf::getNXDNGatewayPort() const +unsigned short CConf::getNXDNGatewayPort() const { return m_nxdnGatewayPort; } @@ -2127,7 +2162,7 @@ std::string CConf::getNXDNLocalAddress() const return m_nxdnLocalAddress; } -unsigned int CConf::getNXDNLocalPort() const +unsigned short CConf::getNXDNLocalPort() const { return m_nxdnLocalPort; } @@ -2152,12 +2187,17 @@ std::string CConf::getM17GatewayAddress() const return m_m17GatewayAddress; } -unsigned int CConf::getM17GatewayPort() const +unsigned short CConf::getM17GatewayPort() const { return m_m17GatewayPort; } -unsigned int CConf::getM17LocalPort() const +std::string CConf::getM17LocalAddress() const +{ + return m_m17LocalAddress; +} + +unsigned short CConf::getM17LocalPort() const { return m_m17LocalPort; } @@ -2182,7 +2222,7 @@ std::string CConf::getPOCSAGGatewayAddress() const return m_pocsagGatewayAddress; } -unsigned int CConf::getPOCSAGGatewayPort() const +unsigned short CConf::getPOCSAGGatewayPort() const { return m_pocsagGatewayPort; } @@ -2192,7 +2232,7 @@ std::string CConf::getPOCSAGLocalAddress() const return m_pocsagLocalAddress; } -unsigned int CConf::getPOCSAGLocalPort() const +unsigned short CConf::getPOCSAGLocalPort() const { return m_pocsagLocalPort; } @@ -2222,7 +2262,7 @@ std::string CConf::getFMGatewayAddress() const return m_fmGatewayAddress; } -unsigned int CConf::getFMGatewayPort() const +unsigned short CConf::getFMGatewayPort() const { return m_fmGatewayPort; } @@ -2232,7 +2272,7 @@ std::string CConf::getFMLocalAddress() const return m_fmLocalAddress; } -unsigned int CConf::getFMLocalPort() const +unsigned short CConf::getFMLocalPort() const { return m_fmLocalPort; } @@ -2417,12 +2457,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; } @@ -2467,7 +2507,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 447194c..fc45d4b 100644 --- a/Conf.h +++ b/Conf.h @@ -76,8 +76,9 @@ public: std::string getModemI2CPort() const; unsigned int getModemI2CAddress() const; std::string getModemModemAddress() const; - unsigned int getModemModemPort() const; - unsigned int getModemLocalPort() const; + unsigned short getModemModemPort() const; + std::string getModemLocalAddress() const; + unsigned short getModemLocalPort() const; bool getModemRXInvert() const; bool getModemTXInvert() const; bool getModemPTTInvert() const; @@ -107,8 +108,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 D-Star section @@ -231,17 +232,19 @@ 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; + std::string getDStarLocalAddress() const; + unsigned short getDStarLocalPort() const; unsigned int getDStarNetworkModeHang() const; bool getDStarNetworkDebug() const; // The DMR Network section bool getDMRNetworkEnabled() const; std::string getDMRNetworkType() const; - std::string getDMRNetworkAddress() const; - unsigned int getDMRNetworkPort() const; - unsigned int 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,18 +255,19 @@ public: // The System Fusion Network section bool getFusionNetworkEnabled() const; - std::string getFusionNetworkMyAddress() const; - unsigned int getFusionNetworkMyPort() const; + std::string getFusionNetworkLocalAddress() const; + unsigned short getFusionNetworkLocalPort() 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; + std::string getP25LocalAddress() const; + unsigned short getP25LocalPort() const; unsigned int getP25NetworkModeHang() const; bool getP25NetworkDebug() const; @@ -271,26 +275,27 @@ 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 M17 Network section bool getM17NetworkEnabled() const; std::string getM17GatewayAddress() const; - unsigned int getM17GatewayPort() const; - unsigned int getM17LocalPort() const; + unsigned short getM17GatewayPort() const; + std::string getM17LocalAddress() const; + unsigned short getM17LocalPort() const; unsigned int getM17NetworkModeHang() const; bool getM17NetworkDebug() 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,9 +303,9 @@ public: bool getFMNetworkEnabled() const; std::string getFMNetworkProtocol() const; std::string getFMGatewayAddress() const; - unsigned int getFMGatewayPort() const; + unsigned short getFMGatewayPort() const; std::string getFMLocalAddress() const; - unsigned int getFMLocalPort() const; + unsigned short getFMLocalPort() const; bool getFMPreEmphasis() const; bool getFMDeEmphasis() const; float getFMTXAudioGain() const; @@ -350,8 +355,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; @@ -363,7 +368,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; @@ -406,8 +411,9 @@ private: std::string m_modemI2CPort; unsigned int m_modemI2CAddress; std::string m_modemModemAddress; - unsigned int m_modemModemPort; - unsigned int m_modemLocalPort; + unsigned short m_modemModemPort; + std::string m_modemLocalAddress; + unsigned short m_modemLocalPort; bool m_modemRXInvert; bool m_modemTXInvert; bool m_modemPTTInvert; @@ -436,8 +442,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_dstarEnabled; @@ -550,16 +556,18 @@ private: bool m_dstarNetworkEnabled; std::string m_dstarGatewayAddress; - unsigned int m_dstarGatewayPort; - unsigned int m_dstarLocalPort; + 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 int m_dmrNetworkPort; - unsigned int 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; @@ -569,50 +577,52 @@ private: unsigned int m_dmrNetworkModeHang; bool m_fusionNetworkEnabled; - std::string m_fusionNetworkMyAddress; - unsigned int m_fusionNetworkMyPort; + std::string m_fusionNetworkLocalAddress; + unsigned short m_fusionNetworkLocalPort; 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; + std::string m_p25LocalAddress; + 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_m17NetworkEnabled; std::string m_m17GatewayAddress; - unsigned int m_m17GatewayPort; - unsigned int m_m17LocalPort; + unsigned short m_m17GatewayPort; + std::string m_m17LocalAddress; + unsigned short m_m17LocalPort; unsigned int m_m17NetworkModeHang; bool m_m17NetworkDebug; 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; bool m_fmNetworkEnabled; std::string m_fmNetworkProtocol; std::string m_fmGatewayAddress; - unsigned int m_fmGatewayPort; + unsigned short m_fmGatewayPort; std::string m_fmLocalAddress; - unsigned int m_fmLocalPort; + unsigned short m_fmLocalPort; bool m_fmPreEmphasis; bool m_fmDeEmphasis; float m_fmTXAudioGain; @@ -656,8 +666,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; @@ -667,7 +677,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..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 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, 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 6df82cc..5d6a959 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& 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); @@ -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..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 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, 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 7bca94f..160dc51 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& 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); @@ -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 eae4f8f..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 int gatewayPort, unsigned int 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 cb41b78..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 int gatewayPort, unsigned int 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/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..48d2382 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 short localPort, const std::string& gatewayAddress, unsigned short 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..606bad6 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& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short 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/LCDproc.cpp b/LCDproc.cpp index 0ef66eb..43595a8 100644 --- a/LCDproc.cpp +++ b/LCDproc.cpp @@ -97,7 +97,7 @@ const unsigned int P25_RSSI_COUNT = 7U; // 7 * 180ms = 1260ms const unsigned int NXDN_RSSI_COUNT = 28U; // 28 * 40ms = 1120ms const unsigned int M17_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 553968a..aee8214 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(); @@ -77,7 +77,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/M17Network.cpp b/M17Network.cpp index 2fd213d..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 int localPort, const std::string& gwyAddress, unsigned int 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 9fc555a..dbc2b2c 100644 --- a/M17Network.h +++ b/M17Network.h @@ -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,7 +29,7 @@ class CM17Network { public: - CM17Network(unsigned int localPort, const std::string& gwyAddress, unsigned int 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 f4fe528..8964fdf 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 6dadeff..4b430cb 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -359,14 +359,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) { @@ -693,11 +693,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); @@ -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); @@ -1539,18 +1541,20 @@ 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(); + std::string localAddress = m_conf.getDStarLocalAddress(); + 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 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 int port = m_conf.getDMRNetworkPort(); - unsigned int 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: %u", port); - if (local > 0U) - LogInfo(" Local: %u", 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 int myPort = m_conf.getFusionNetworkMyPort(); + std::string localAddress = m_conf.getFusionNetworkLocalAddress(); + unsigned short localPort = m_conf.getFusionNetworkLocalPort(); 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 Address: %s", localAddress.c_str()); + LogInfo(" Local Port: %hu", localPort); 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); + m_ysfNetwork = new CYSFNetwork(localAddress, localPort, gatewayAddress, gatewayPort, m_callsign, debug); bool ret = m_ysfNetwork->open(); if (!ret) { @@ -1681,18 +1684,20 @@ 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(); + std::string localAddress = m_conf.getP25LocalAddress(); + 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 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) { @@ -1710,18 +1715,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") @@ -1744,18 +1749,20 @@ bool CMMDVMHost::createNXDNNetwork() bool CMMDVMHost::createM17Network() { std::string gatewayAddress = m_conf.getM17GatewayAddress(); - unsigned int gatewayPort = m_conf.getM17GatewayPort(); - unsigned int localPort = m_conf.getM17LocalPort(); + 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(); LogInfo("M17 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 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; @@ -1771,17 +1778,17 @@ bool CMMDVMHost::createM17Network() 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); @@ -1800,11 +1807,12 @@ 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(); + unsigned short gatewayPort = m_conf.getFMGatewayPort(); std::string localAddress = m_conf.getFMLocalAddress(); - unsigned int localPort = m_conf.getFMLocalPort(); + unsigned short localPort = m_conf.getFMLocalPort(); bool preEmphasis = m_conf.getFMPreEmphasis(); bool deEmphasis = m_conf.getFMDeEmphasis(); float txAudioGain = m_conf.getFMTXAudioGain(); @@ -1815,16 +1823,16 @@ bool CMMDVMHost::createFMNetwork() LogInfo("FM 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(" Pre-Emphasis: %s", preEmphasis ? "yes" : "no"); LogInfo(" De-Emphasis: %s", deEmphasis ? "yes" : "no"); LogInfo(" TX Audio Gain: %.2f", txAudioGain); 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/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..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 int gatewayPort, unsigned int 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 6b8407c..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 int gatewayPort, unsigned int 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 c0437bd..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 int myPort, const std::string& gatewayAddress, unsigned int 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 693f5ac..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 int myPort, const std::string& gatewayAddress, unsigned int 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/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/Version.h b/Version.h index 4498807..69f184a 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 = "20210425"; #endif diff --git a/YSFNetwork.cpp b/YSFNetwork.cpp index 525ebbe..727a1a0 100644 --- a/YSFNetwork.cpp +++ b/YSFNetwork.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 @@ -28,8 +28,8 @@ 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) : -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 0fdbb67..918134b 100644 --- a/YSFNetwork.h +++ b/YSFNetwork.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 @@ -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& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& callsign, bool debug); ~CYSFNetwork(); bool open();