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] 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); +}