From bf6577e2ca505097b84a2f445f83df7ba834a34a Mon Sep 17 00:00:00 2001 From: Chipster Date: Wed, 4 Oct 2023 11:11:56 -0500 Subject: [PATCH] Reverses PR #306, which broke FCS Remote/Dynamic linking --- YSFGateway/Conf.cpp | 16 --------------- YSFGateway/Conf.h | 4 ---- YSFGateway/WiresX.cpp | 11 +--------- YSFGateway/WiresX.h | 1 - YSFGateway/YSFGateway.cpp | 40 ++++++++++-------------------------- YSFGateway/YSFGateway.ini | 2 -- YSFGateway/YSFReflectors.cpp | 33 ----------------------------- YSFGateway/YSFReflectors.h | 3 --- 8 files changed, 12 insertions(+), 98 deletions(-) diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index 55ac4db..c9e39a9 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -88,8 +88,6 @@ m_ysfNetworkYSF2NXDNAddress("127.0.0.1"), m_ysfNetworkYSF2NXDNPort(0U), m_ysfNetworkYSF2P25Address("127.0.0.1"), m_ysfNetworkYSF2P25Port(0U), -m_ysfNetworkYSFDirectAddress("127.0.0.1"), -m_ysfNetworkYSFDirectPort(0U), m_fcsNetworkEnabled(false), m_fcsNetworkFile(), m_fcsNetworkPort(0U), @@ -276,10 +274,6 @@ bool CConf::read() m_ysfNetworkYSF2P25Address = value; else if (::strcmp(key, "YSF2P25Port") == 0) m_ysfNetworkYSF2P25Port = (unsigned short)::atoi(value); - else if (::strcmp(key, "YSFDirectAddress") == 0) - m_ysfNetworkYSFDirectAddress = value; - else if (::strcmp(key, "YSFDirectPort") == 0) - m_ysfNetworkYSFDirectPort = (unsigned short)::atoi(value); } else if (section == SECTION_FCS_NETWORK) { if (::strcmp(key, "Enable") == 0) m_fcsNetworkEnabled = ::atoi(value) == 1; @@ -542,16 +536,6 @@ unsigned short CConf::getYSFNetworkYSF2P25Port() const return m_ysfNetworkYSF2P25Port; } -std::string CConf::getYSFNetworkYSFDirectAddress() const -{ - return m_ysfNetworkYSFDirectAddress; -} - -unsigned short CConf::getYSFNetworkYSFDirectPort() const -{ - return m_ysfNetworkYSFDirectPort; -} - bool CConf::getFCSNetworkEnabled() const { diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index aecdbbd..430613d 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -87,8 +87,6 @@ public: unsigned short getYSFNetworkYSF2NXDNPort() const; std::string getYSFNetworkYSF2P25Address() const; unsigned short getYSFNetworkYSF2P25Port() const; - std::string getYSFNetworkYSFDirectAddress() const; - unsigned short getYSFNetworkYSFDirectPort() const; // The FCS Network section bool getFCSNetworkEnabled() const; @@ -158,8 +156,6 @@ private: unsigned short m_ysfNetworkYSF2NXDNPort; std::string m_ysfNetworkYSF2P25Address; unsigned short m_ysfNetworkYSF2P25Port; - std::string m_ysfNetworkYSFDirectAddress; - unsigned short m_ysfNetworkYSFDirectPort; bool m_fcsNetworkEnabled; std::string m_fcsNetworkFile; diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index f2d9304..179f0aa 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -173,11 +173,6 @@ void CWiresX::setYSF2P25(const std::string& address, unsigned short port) m_reflectors.setYSF2P25(address, port); } -void CWiresX::setYSFDirect(const std::string& address, unsigned short port) -{ - m_reflectors.setYSFDirect(address, port); -} - void CWiresX::addFCSRoom(const std::string& id, const std::string& name) { m_reflectors.addFCSRoom(id, name); @@ -378,11 +373,7 @@ WX_STATUS CWiresX::processConnect(const unsigned char* source, const unsigned ch std::string id = std::string((char*)data, 5U); - CYSFReflector* reflector_tmp; - reflector_tmp = m_reflectors.findById(id); - if (reflector_tmp != NULL) - m_reflector = reflector_tmp; - + m_reflector = m_reflectors.findById(id); if (m_reflector == NULL) return WXS_NONE; diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index df7cd40..7901c2b 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -55,7 +55,6 @@ public: void setYSF2DMR(const std::string& address, unsigned short port); void setYSF2NXDN(const std::string& address, unsigned short port); void setYSF2P25(const std::string& address, unsigned short port); - void setYSFDirect(const std::string& address, unsigned short port); void addFCSRoom(const std::string& id, const std::string& name); bool start(); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index f051dda..bc6e948 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -273,8 +273,7 @@ int CYSFGateway::run() for (;;) { unsigned char buffer[200U]; memset(buffer, 0U, 200U); - bool wx_tmp; - + while (rptNetwork.read(buffer) > 0U) { CYSFFICH fich; bool valid = fich.decode(buffer + 35U); @@ -283,22 +282,14 @@ int CYSFGateway::run() unsigned char dt = fich.getDT(); CYSFReflector* reflector = m_wiresX->getReflector(); - if (reflector != NULL) - wx_tmp = reflector->m_wiresX; - else - wx_tmp = false; - if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wiresXCommandPassthrough && wx_tmp) { + if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wiresXCommandPassthrough && reflector->m_wiresX) { processDTMF(buffer, dt); processWiresX(buffer, fich, true, wiresXCommandPassthrough); } else { processDTMF(buffer, dt); processWiresX(buffer, fich, false, wiresXCommandPassthrough); reflector = m_wiresX->getReflector(); //reflector may have changed - if (reflector != NULL) - wx_tmp = reflector->m_wiresX; - else - wx_tmp = false; - if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wx_tmp) + if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && reflector->m_wiresX) m_exclude = (dt == YSF_DT_DATA_FR_MODE); } @@ -539,11 +530,6 @@ void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork) if (port > 0U) m_wiresX->setYSF2P25(address, port); - address = m_conf.getYSFNetworkYSFDirectAddress(); - port = m_conf.getYSFNetworkYSFDirectPort(); - if (port > 0U) - m_wiresX->setYSFDirect(address, port); - std::string filename = m_conf.getFCSNetworkFile(); if (m_fcsNetworkEnabled) readFCSRoomsFile(filename); @@ -840,8 +826,6 @@ void CYSFGateway::startupLinking() m_linkType = LINK_NONE; CYSFReflector* reflector = m_reflectors->findByName(m_startup); - if (reflector == NULL) - reflector = m_reflectors->findById(m_startup); if (reflector != NULL) { LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); @@ -899,11 +883,10 @@ void CYSFGateway::processRemoteCommands() int res = m_remoteSocket->read(buffer, 200U, addr, addrLen); if (res > 0) { buffer[res] = '\0'; - if ((::memcmp(buffer + 0U, "LinkYSF", 7U) == 0) && (strlen((char*)buffer + 0U) > 8) && (m_ysfNetwork != NULL)) { - std::string id = std::string((char*)(buffer + 7U)); + if ((::memcmp(buffer + 0U, "LinkYSF", 7U) == 0) && (strlen((char*)buffer + 0U) > 8)) { + std::string id = std::string((char*)(buffer + 8U)); // Left trim - // id.erase(id.begin(), std::find_if(id.begin(), id.end(), std::not1(std::ptr_fun(std::isspace)))); - id.erase(std::remove_if(id.begin(), id.end(), [](char c) { return !std::isalnum(c); }), id.end()); + id.erase(id.begin(), std::find_if(id.begin(), id.end(), std::not1(std::ptr_fun(std::isspace)))); CYSFReflector* reflector = m_reflectors->findById(id); if (reflector == NULL) reflector = m_reflectors->findByName(id); @@ -931,11 +914,10 @@ void CYSFGateway::processRemoteCommands() LogWarning("Invalid YSF reflector id/name - \"%s\"", id.c_str()); return; } - } else if ((::memcmp(buffer + 0U, "LinkFCS", 7U) == 0) && (strlen((char*)buffer + 0U) > 8) && (m_fcsNetwork != NULL)) { - std::string raw = std::string((char*)(buffer + 7U)); + } else if ((::memcmp(buffer + 0U, "LinkFCS", 7U) == 0) && (strlen((char*)buffer + 0U) > 8)) { + std::string raw = std::string((char*)(buffer + 8U)); // Left trim - // raw.erase(raw.begin(), std::find_if(raw.begin(), raw.end(), std::not1(std::ptr_fun(std::isspace)))); - raw.erase(std::remove_if(raw.begin(), raw.end(), [](char c) { return !std::isalnum(c); }), raw.end()); + raw.erase(raw.begin(), std::find_if(raw.begin(), raw.end(), std::not1(std::ptr_fun(std::isspace)))); std::string id = "FCS00"; std::string idShort = "FCS"; if (raw.length() == 3U) { @@ -959,7 +941,7 @@ void CYSFGateway::processRemoteCommands() m_current.clear(); m_inactivityTimer.stop(); m_lostTimer.stop(); - m_linkType = LINK_FCS; + m_linkType = LINK_NONE; LogMessage("Connect by remote command to %s", id.c_str()); @@ -968,7 +950,7 @@ void CYSFGateway::processRemoteCommands() m_current = id; m_inactivityTimer.start(); m_lostTimer.start(); - m_linkType = LINK_NONE; + m_linkType = LINK_FCS; } else { LogMessage("Unknown reflector - %s", id.c_str()); } diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 96b8993..bdfef4c 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -60,8 +60,6 @@ YSF2NXDNAddress=127.0.0.1 YSF2NXDNPort=42014 YSF2P25Address=127.0.0.1 YSF2P25Port=42015 -YSFDirectAddress=127.0.0.1 -YSFDirectPort=42016 [FCS Network] Enable=1 diff --git a/YSFGateway/YSFReflectors.cpp b/YSFGateway/YSFReflectors.cpp index ed0c0c0..129b20c 100644 --- a/YSFGateway/YSFReflectors.cpp +++ b/YSFGateway/YSFReflectors.cpp @@ -36,8 +36,6 @@ m_YSF2NXDNAddress(), m_YSF2NXDNPort(0U), m_YSF2P25Address(), m_YSF2P25Port(0U), -m_YSFDirectAddress(), -m_YSFDirectPort(0U), m_fcsRooms(), m_newReflectors(), m_currReflectors(), @@ -102,12 +100,6 @@ void CYSFReflectors::setYSF2P25(const std::string& address, unsigned short port) m_YSF2P25Port = port; } -void CYSFReflectors::setYSFDirect(const std::string& address, unsigned short port) -{ - m_YSFDirectAddress = address; - m_YSFDirectPort = port; -} - void CYSFReflectors::addFCSRoom(const std::string& id, const std::string& name) { m_fcsRooms.push_back(std::make_pair(id, name)); @@ -260,31 +252,6 @@ bool CYSFReflectors::load() } } - // Add the YSFDirect entry - if (m_YSFDirectPort > 0U) { - sockaddr_storage addr; - unsigned int addrLen; - if (CUDPSocket::lookup(m_YSFDirectAddress, m_YSFDirectPort, addr, addrLen) == 0) { - CYSFReflector* refl = new CYSFReflector; - refl->m_id = "00006"; - refl->m_name = "YSFDIRECT "; - refl->m_desc = "Link YSFDirect"; - refl->m_addr = addr; - refl->m_addrLen = addrLen; - refl->m_count = "000"; - refl->m_type = YT_YSF; - refl->m_wiresX = true; - - m_newReflectors.push_back(refl); - - LogInfo("Loaded YSFDirect"); - } else { - LogWarning("Unable to resolve the address of YSFDirect"); - } - } - - - unsigned int id = 9U; for (std::vector>::const_iterator it1 = m_fcsRooms.cbegin(); it1 != m_fcsRooms.cend(); ++it1) { bool used; diff --git a/YSFGateway/YSFReflectors.h b/YSFGateway/YSFReflectors.h index eea7e63..00c8184 100644 --- a/YSFGateway/YSFReflectors.h +++ b/YSFGateway/YSFReflectors.h @@ -63,7 +63,6 @@ public: void setYSF2DMR(const std::string& address, unsigned short port); void setYSF2NXDN(const std::string& address, unsigned short port); void setYSF2P25(const std::string& address, unsigned short port); - void setYSFDirect(const std::string& address, unsigned short port); void addFCSRoom(const std::string& id, const std::string& name); bool load(); @@ -89,8 +88,6 @@ private: unsigned short m_YSF2NXDNPort; std::string m_YSF2P25Address; unsigned short m_YSF2P25Port; - std::string m_YSFDirectAddress; - unsigned short m_YSFDirectPort; std::vector> m_fcsRooms; std::vector m_newReflectors; std::vector m_currReflectors;