From 23c3cfeaec24eb36ef15a426ba2262a0ff946566 Mon Sep 17 00:00:00 2001 From: dg9ffm <63248214+dg9ffm@users.noreply.github.com> Date: Fri, 4 Sep 2020 13:14:01 +0200 Subject: [PATCH 01/13] Update FCSNetwork.cpp use m_address to resolve FCSxxx.xreflector.net. all servers have the same domain name. --- YSFGateway/FCSNetwork.cpp | 58 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 798a827..2f946c8 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -34,6 +34,7 @@ m_socket(port), m_debug(debug), m_address(), m_ping(NULL), +m_options(NULL), m_info(NULL), m_reflector(), m_print(), @@ -52,18 +53,25 @@ m_state(FCS_UNLINKED) ::memset(m_ping + 4U, ' ', 6U); ::memcpy(m_ping + 4U, callsign.c_str(), callsign.size()); ::memset(m_ping + 10U, 0x00U, 15U); + + m_options = new unsigned char[50U]; + ::memcpy(m_options + 0U, "FCSO", 4U); + ::memset(m_options + 4U, ' ', 46U); + ::memcpy(m_options + 4U, callsign.c_str(), callsign.size()); } CFCSNetwork::~CFCSNetwork() { delete[] m_info; delete[] m_ping; + delete[] m_options; } bool CFCSNetwork::open() { LogMessage("Resolving FCS00x addresses"); + /* OE1KBC not needed see ::writeLink m_addresses["FCS001"] = CUDPSocket::lookup("fcs001.xreflector.net"); m_addresses["FCS002"] = CUDPSocket::lookup("fcs002.xreflector.net"); m_addresses["FCS003"] = CUDPSocket::lookup("fcs003.xreflector.net"); @@ -74,8 +82,10 @@ bool CFCSNetwork::open() m_addresses["FCS232"] = CUDPSocket::lookup("fcs232.xreflector.net"); m_addresses["FCS260"] = CUDPSocket::lookup("fcs260.xreflector.net"); m_addresses["FCS262"] = CUDPSocket::lookup("fcs262.xreflector.net"); + */ + // OE1KBC 2020-09-04 + m_addresses["FCS999"] = CUDPSocket::lookup("fcs999.xreflector.net"); - LogMessage("Opening FCS network connection"); return m_socket.open(); @@ -111,12 +121,28 @@ bool CFCSNetwork::writeLink(const std::string& reflector) { if (m_state != FCS_LINKED) { std::string name = reflector.substr(0U, 6U); + + ///////////////////////////////////////////////////////////////////// + // OE1KBC 2020-09-04 if (m_addresses.count(name) == 0U) { - LogError("Unknown FCS reflector - %s", name.c_str()); - return false; + + char fcs_url[30U]; + ::sprintf(fcs_url, "%s.xreflector.net", name.c_str()); + m_address = CUDPSocket::lookup(fcs_url); + + if(m_address.s_addr == INADDR_NONE) + { + LogError("Unknown FCS reflector - %s", name.c_str()); + return false; + } } + else + m_address = m_addresses[name]; + // + ///////////////////////////////////////////////////////////////////// + + - m_address = m_addresses[name]; if (m_address.s_addr == INADDR_NONE) { LogError("FCS reflector %s has no address", name.c_str()); return false; @@ -137,6 +163,11 @@ bool CFCSNetwork::writeLink(const std::string& reflector) return true; } +void CFCSNetwork::setOptions(const std::string& options) +{ + m_opt = options; +} + void CFCSNetwork::writeUnlink(unsigned int count) { if (m_state != FCS_LINKED) @@ -182,12 +213,14 @@ void CFCSNetwork::clock(unsigned int ms) LogMessage("Linked to %s", m_print.c_str()); m_state = FCS_LINKED; writeInfo(); + writeOptions(); } if (length == 10 && m_state == FCS_LINKING) { LogMessage("Linked to %s", m_print.c_str()); m_state = FCS_LINKED; writeInfo(); + writeOptions(); } if (length == 7 || length == 10 || length == 130) { @@ -264,3 +297,20 @@ void CFCSNetwork::writePing() m_socket.write(m_ping, 25U, m_address, FCS_PORT); } + +void CFCSNetwork::writeOptions() +{ + if (m_state != FCS_LINKED) + return; + + if (m_opt.size() < 1) + return; + + ::memset(m_options + 14U, 0x20U, 36U); + ::memcpy(m_options + 14U, m_opt.c_str(), m_opt.size()); + + if (m_debug) + CUtils::dump(1U, "FCS Network Options Sent", m_options, 50U); + + m_socket.write(m_options, 50U, m_address, FCS_PORT); +} From 70c9598df0dcb01acebfa31d900a130e2759f497 Mon Sep 17 00:00:00 2001 From: Merlinv3 <59935740+Merlinv3@users.noreply.github.com> Date: Sat, 5 Sep 2020 08:31:20 +0200 Subject: [PATCH 02/13] Update FCSNetwork.cpp pleaase Update for new fcs310 thx! --- YSFGateway/FCSNetwork.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 798a827..ff67012 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -74,6 +74,7 @@ bool CFCSNetwork::open() m_addresses["FCS232"] = CUDPSocket::lookup("fcs232.xreflector.net"); m_addresses["FCS260"] = CUDPSocket::lookup("fcs260.xreflector.net"); m_addresses["FCS262"] = CUDPSocket::lookup("fcs262.xreflector.net"); + m_addresses["FCS310"] = CUDPSocket::lookup("fcs310.xreflector.net"); LogMessage("Opening FCS network connection"); From a0ef2bc297d8d9be619b840bbc8988cbd6fe89c9 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 08:56:18 +0200 Subject: [PATCH 03/13] Update FCSNetwork.cpp --- YSFGateway/FCSNetwork.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 798a827..2b3aefd 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -99,6 +99,11 @@ void CFCSNetwork::write(const unsigned char* data) unsigned char buffer[130U]; ::memset(buffer + 0U, ' ', 130U); ::memcpy(buffer + 0U, data + 35U, 120U); + + // OE1KBC 2020-09-05 frame# was missing + ::memcpy(buffer + 120U, data + 34U, 1U); + // + ::memcpy(buffer + 121U, m_reflector.c_str(), 8U); if (m_debug) From d2703bf42e828388dfc376c1300fc7995b3a542f Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 21:37:17 +0200 Subject: [PATCH 04/13] Update FCSNetwork.cpp line 86 end of comment is missing. --- YSFGateway/FCSNetwork.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 3e05f7e..1ab7d83 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -83,6 +83,7 @@ bool CFCSNetwork::open() m_addresses["FCS260"] = CUDPSocket::lookup("fcs260.xreflector.net"); m_addresses["FCS262"] = CUDPSocket::lookup("fcs262.xreflector.net"); m_addresses["FCS310"] = CUDPSocket::lookup("fcs310.xreflector.net"); + */ m_addresses["FCS999"] = CUDPSocket::lookup("fcs999.xreflector.net"); LogMessage("Opening FCS network connection"); @@ -135,9 +136,9 @@ bool CFCSNetwork::writeLink(const std::string& reflector) LogError("Unknown FCS reflector - %s", name.c_str()); return false; } - } else { + } else { m_address = m_addresses[name]; - } + } if (m_address.s_addr == INADDR_NONE) { LogError("FCS reflector %s has no address", name.c_str()); From 0e9288b133c249c9b9f4dec8ca27d10df4dd1da1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 5 Sep 2020 21:14:17 +0100 Subject: [PATCH 05/13] Clear up the mess left by OE1KBC. --- YSFGateway/FCSNetwork.cpp | 22 +++------------------- YSFGateway/FCSNetwork.h | 5 +++++ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 1ab7d83..38305ff 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -35,6 +35,7 @@ m_debug(debug), m_address(), m_ping(NULL), m_options(NULL), +m_opt(), m_info(NULL), m_reflector(), m_print(), @@ -69,21 +70,8 @@ CFCSNetwork::~CFCSNetwork() bool CFCSNetwork::open() { - LogMessage("Resolving FCS00x addresses"); - - /* OE1KBC not needed see ::writeLink - m_addresses["FCS001"] = CUDPSocket::lookup("fcs001.xreflector.net"); - m_addresses["FCS002"] = CUDPSocket::lookup("fcs002.xreflector.net"); - m_addresses["FCS003"] = CUDPSocket::lookup("fcs003.xreflector.net"); - m_addresses["FCS004"] = CUDPSocket::lookup("fcs004.xreflector.net"); - m_addresses["FCS005"] = CUDPSocket::lookup("fcs005.xreflector.net"); - m_addresses["FCS222"] = CUDPSocket::lookup("fcs222.xreflector.net"); - m_addresses["FCS224"] = CUDPSocket::lookup("fcs224.xreflector.net"); - m_addresses["FCS232"] = CUDPSocket::lookup("fcs232.xreflector.net"); - m_addresses["FCS260"] = CUDPSocket::lookup("fcs260.xreflector.net"); - m_addresses["FCS262"] = CUDPSocket::lookup("fcs262.xreflector.net"); - m_addresses["FCS310"] = CUDPSocket::lookup("fcs310.xreflector.net"); - */ + LogMessage("Resolving FCS999 address"); + m_addresses["FCS999"] = CUDPSocket::lookup("fcs999.xreflector.net"); LogMessage("Opening FCS network connection"); @@ -109,11 +97,7 @@ void CFCSNetwork::write(const unsigned char* data) unsigned char buffer[130U]; ::memset(buffer + 0U, ' ', 130U); ::memcpy(buffer + 0U, data + 35U, 120U); - - // OE1KBC 2020-09-05 frame# was missing ::memcpy(buffer + 120U, data + 34U, 1U); - // - ::memcpy(buffer + 121U, m_reflector.c_str(), 8U); if (m_debug) diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index 0dd0d18..b43beb3 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -41,6 +41,8 @@ public: bool open(); + void setOptions(const std::string& options); + void clearDestination(); void write(const unsigned char* data); @@ -60,6 +62,8 @@ private: bool m_debug; in_addr m_address; unsigned char* m_ping; + unsigned char* m_options; + std::string m_opt; unsigned char* m_info; std::string m_reflector; std::string m_print; @@ -70,6 +74,7 @@ private: CTimer m_resetTimer; FCS_STATE m_state; + void writeOptions(); void writeInfo(); void writePing(); }; From 30b9bbdb3810a97b8c9ace733541fc0f2d0895d4 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 22:33:53 +0200 Subject: [PATCH 06/13] Update Conf.h --- YSFGateway/Conf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 7f07a9c..e050599 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -67,6 +67,7 @@ public: // The Network section std::string getNetworkStartup() const; + std::string getNetworkOptions() const; unsigned int getNetworkInactivityTimeout() const; bool getNetworkRevert() const; bool getNetworkDebug() const; @@ -134,6 +135,7 @@ private: std::string m_aprsDescription; std::string m_networkStartup; + std::string m_networkOptions; unsigned int m_networkInactivityTimeout; bool m_networkRevert; bool m_networkDebug; From 9b698b5d8cdcf0286fd06a0033544da6c9940aec Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 22:37:20 +0200 Subject: [PATCH 07/13] Update Conf.cpp --- YSFGateway/Conf.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index eb5b2b4..50497b7 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -70,6 +70,7 @@ m_aprsPort(0U), m_aprsSuffix(), m_aprsDescription(), m_networkStartup(), +m_networkOptions(), m_networkInactivityTimeout(0U), m_networkRevert(false), m_networkDebug(false), @@ -214,6 +215,8 @@ bool CConf::read() } else if (section == SECTION_NETWORK) { if (::strcmp(key, "Startup") == 0) m_networkStartup = value; + else if (::strcmp(key, "Options") == 0) + m_networkOptions = value; else if (::strcmp(key, "InactivityTimeout") == 0) m_networkInactivityTimeout = (unsigned int)::atoi(value); else if (::strcmp(key, "Revert") == 0) @@ -417,6 +420,11 @@ std::string CConf::getNetworkStartup() const return m_networkStartup; } +std::string CConf::getNetworkOptions() const +{ + return m_networkOptions; +} + unsigned int CConf::getNetworkInactivityTimeout() const { return m_networkInactivityTimeout; From 07690aa58340e85c7241276e06194a35488aeaa3 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 22:40:04 +0200 Subject: [PATCH 08/13] Update YSFGateway.h Add OPTIONS --- YSFGateway/YSFGateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index b74db45..c0d75ce 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -59,6 +59,7 @@ private: LINK_TYPE m_linkType; std::string m_current; std::string m_startup; + std::string m_options; bool m_exclude; CTimer m_inactivityTimer; CTimer m_lostTimer; From d1c8e34cea5f176dbd99190e524c426fced30bbf Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 22:45:25 +0200 Subject: [PATCH 09/13] Update YSFGateway.cpp ADD OPTIONS= --- YSFGateway/YSFGateway.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 27fd83e..fb23724 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -89,6 +89,7 @@ m_fcsNetwork(NULL), m_linkType(LINK_NONE), m_current(), m_startup(), +m_options(), m_exclude(false), m_inactivityTimer(1000U), m_lostTimer(1000U, 120U), @@ -254,6 +255,7 @@ int CYSFGateway::run() } m_startup = m_conf.getNetworkStartup(); + m_options = m_conf.getNetworkOptions(); bool revert = m_conf.getNetworkRevert(); bool wiresXCommandPassthrough = m_conf.getWiresXCommandPassthrough(); @@ -803,6 +805,8 @@ void CYSFGateway::startupLinking() m_linkType = LINK_NONE; bool ok = m_fcsNetwork->writeLink(m_startup); + m_fcsNetwork->setOptions(m_options); + if (ok) { LogMessage("Automatic (re-)connection to %s", m_startup.c_str()); @@ -823,6 +827,8 @@ void CYSFGateway::startupLinking() if (reflector != NULL) { LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); + m_ysfNetwork->setOptions(m_options); + m_wiresX->setReflector(reflector); m_ysfNetwork->setDestination(reflector->m_name, reflector->m_address, reflector->m_port); From cb155e104dce6656decffb2bd30f68b3029ca452 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 22:47:41 +0200 Subject: [PATCH 10/13] Update YSFNetwork.h --- YSFGateway/YSFNetwork.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/YSFGateway/YSFNetwork.h b/YSFGateway/YSFNetwork.h index 30bfb39..2f89b69 100644 --- a/YSFGateway/YSFNetwork.h +++ b/YSFGateway/YSFNetwork.h @@ -41,6 +41,7 @@ public: void write(const unsigned char* data); void writePoll(unsigned int count = 1U); + void setOptions(const std::string& options = NULL); void writeUnlink(unsigned int count = 1U); unsigned int read(unsigned char* data); @@ -55,6 +56,7 @@ private: in_addr m_address; unsigned int m_port; unsigned char* m_poll; + unsigned char* m_options; unsigned char* m_unlink; CRingBuffer m_buffer; CTimer m_pollTimer; From ee224039bec1ff9a2419758b01e83214a8f1d4f5 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 22:51:45 +0200 Subject: [PATCH 11/13] Update YSFNetwork.cpp --- YSFGateway/YSFNetwork.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/YSFGateway/YSFNetwork.cpp b/YSFGateway/YSFNetwork.cpp index 91076d1..dad803e 100644 --- a/YSFGateway/YSFNetwork.cpp +++ b/YSFGateway/YSFNetwork.cpp @@ -33,6 +33,7 @@ m_debug(debug), m_address(), m_port(0U), m_poll(NULL), +m_options(NULL), m_unlink(NULL), m_buffer(1000U, "YSF Network Buffer"), m_pollTimer(1000U, 5U), @@ -45,12 +46,16 @@ m_linked(false) m_unlink = new unsigned char[14U]; ::memcpy(m_unlink + 0U, "YSFU", 4U); + m_options = new unsigned char[50U]; + ::memcpy(m_options + 0U, "YSFO", 4U); + std::string node = callsign; node.resize(YSF_CALLSIGN_LENGTH, ' '); for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) { m_poll[i + 4U] = node.at(i); m_unlink[i + 4U] = node.at(i); + m_options[i + 4U] = node.at(i); } } @@ -60,6 +65,7 @@ m_debug(debug), m_address(), m_port(0U), m_poll(NULL), +m_options(NULL), m_unlink(NULL), m_buffer(1000U, "YSF Network Buffer"), m_pollTimer(1000U, 5U) @@ -70,12 +76,16 @@ m_pollTimer(1000U, 5U) m_unlink = new unsigned char[14U]; ::memcpy(m_unlink + 0U, "YSFU", 4U); + m_options = new unsigned char[50U]; + ::memcpy(m_options + 0U, "YSFO", 4U); + std::string node = callsign; node.resize(YSF_CALLSIGN_LENGTH, ' '); for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) { m_poll[i + 4U] = node.at(i); m_unlink[i + 4U] = node.at(i); + m_options[i + 4U] = node.at(i); } } @@ -130,6 +140,23 @@ void CYSFNetwork::writePoll(unsigned int count) for (unsigned int i = 0U; i < count; i++) m_socket.write(m_poll, 14U, m_address, m_port); + + if (m_options != NULL) + m_socket.write(m_options, 50U, m_address, m_port); +} + +void CYSFNetwork::setOptions(const std::string& options) +{ + std::string opt = options; + + if (opt.size() < 1) + return; + + opt.resize(50, ' '); + + for (unsigned int i = 0U; i < (50 - 4 - YSF_CALLSIGN_LENGTH); i++) { + m_options[i + 4U + YSF_CALLSIGN_LENGTH] = opt.at(i); + } } void CYSFNetwork::writeUnlink(unsigned int count) @@ -172,6 +199,9 @@ void CYSFNetwork::clock(unsigned int ms) LogMessage("Linked to %s", m_name.c_str()); m_linked = true; + + if (m_options != NULL) + m_socket.write(m_options, 50U, m_address, m_port); } if (m_debug) From 611fe176403098cb545eccd9822aa3d210880b44 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 5 Sep 2020 22:55:03 +0200 Subject: [PATCH 12/13] Update YSFGateway.ini --- YSFGateway/YSFGateway.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 104909b..c3376c8 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -39,6 +39,8 @@ Suffix=Y [Network] # Startup=FCS00120 # Startup=Alabama-Link +# book DG-ID for Reflector +# Options=20;21; InactivityTimeout=10 Revert=0 Debug=0 From 4a4e046763e6736ef9af0afea03afebae2aeffd4 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 5 Sep 2020 22:11:32 +0100 Subject: [PATCH 13/13] Small cleanups. --- YSFGateway/Conf.cpp | 6 +++--- YSFReflector/Conf.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index 50497b7..784132e 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -382,12 +382,12 @@ unsigned int CConf::getLogFileLevel() const std::string CConf::getLogFilePath() const { - return m_logFilePath; + return m_logFilePath; } std::string CConf::getLogFileRoot() const { - return m_logFileRoot; + return m_logFileRoot; } bool CConf::getAPRSEnabled() const @@ -447,7 +447,7 @@ bool CConf::getYSFNetworkEnabled() const unsigned int CConf::getYSFNetworkPort() const { - return m_ysfNetworkPort; + return m_ysfNetworkPort; } std::string CConf::getYSFNetworkHosts() const diff --git a/YSFReflector/Conf.cpp b/YSFReflector/Conf.cpp index 00fb8df..0ed6f01 100644 --- a/YSFReflector/Conf.cpp +++ b/YSFReflector/Conf.cpp @@ -155,12 +155,12 @@ unsigned int CConf::getLogFileLevel() const std::string CConf::getLogFilePath() const { - return m_logFilePath; + return m_logFilePath; } std::string CConf::getLogFileRoot() const { - return m_logFileRoot; + return m_logFileRoot; } unsigned int CConf::getNetworkPort() const