diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index eda0178..0e7aa6b 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 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 @@ -32,13 +32,16 @@ enum SECTION { SECTION_INFO, SECTION_LOG, SECTION_APRS_FI, - SECTION_NETWORK + SECTION_NETWORK, + SECTION_YSF_NETWORK, + SECTION_FCS_NETWORK }; CConf::CConf(const std::string& file) : m_file(file), m_callsign(), m_suffix(), +m_id(0U), m_rptAddress(), m_rptPort(0U), m_myAddress(), @@ -61,18 +64,20 @@ m_aprsServer(), m_aprsPort(0U), m_aprsPassword(), m_aprsDescription(), -m_networkEnabled(false), -m_networkPort(0U), -m_networkHosts(), -m_networkReloadTime(0U), -m_networkParrotAddress("127.0.0.1"), -m_networkParrotPort(0U), -m_networkYSF2DMRAddress("127.0.0.1"), -m_networkYSF2DMRPort(0U), m_networkStartup(), m_networkInactivityTimeout(0U), m_networkRevert(false), -m_networkDebug(false) +m_networkDebug(false), +m_ysfNetworkEnabled(false), +m_ysfNetworkPort(0U), +m_ysfNetworkHosts(), +m_ysfNetworkReloadTime(0U), +m_ysfNetworkParrotAddress("127.0.0.1"), +m_ysfNetworkParrotPort(0U), +m_ysfNetworkYSF2DMRAddress("127.0.0.1"), +m_ysfNetworkYSF2DMRPort(0U), +m_fcsNetworkEnabled(false), +m_fcsNetworkPort(0U) { } @@ -102,10 +107,14 @@ bool CConf::read() section = SECTION_INFO; else if (::strncmp(buffer, "[Log]", 5U) == 0) section = SECTION_LOG; - else if (::strncmp(buffer, "[aprs.fi]", 5U) == 0) + else if (::strncmp(buffer, "[aprs.fi]", 9U) == 0) section = SECTION_APRS_FI; - else if (::strncmp(buffer, "[Network]", 5U) == 0) + else if (::strncmp(buffer, "[Network]", 9U) == 0) section = SECTION_NETWORK; + else if (::strncmp(buffer, "[YSF Network]", 13U) == 0) + section = SECTION_YSF_NETWORK; + else if (::strncmp(buffer, "[FCS Network]", 13U) == 0) + section = SECTION_FCS_NETWORK; else section = SECTION_NONE; @@ -128,7 +137,9 @@ bool CConf::read() for (unsigned int i = 0U; value[i] != 0; i++) value[i] = ::toupper(value[i]); m_suffix = value; - } else if (::strcmp(key, "RptAddress") == 0) + } else if (::strcmp(key, "Id") == 0) + m_id = (unsigned int)::atoi(value); + else if (::strcmp(key, "RptAddress") == 0) m_rptAddress = value; else if (::strcmp(key, "RptPort") == 0) m_rptPort = (unsigned int)::atoi(value); @@ -176,30 +187,36 @@ bool CConf::read() else if (::strcmp(key, "Description") == 0) m_aprsDescription = value; } else if (section == SECTION_NETWORK) { + if (::strcmp(key, "Startup") == 0) + m_networkStartup = value; + else if (::strcmp(key, "InactivityTimeout") == 0) + m_networkInactivityTimeout = (unsigned int)::atoi(value); + else if (::strcmp(key, "Revert") == 0) + m_networkRevert = ::atoi(value) == 1; + else if (::strcmp(key, "Debug") == 0) + m_networkDebug = ::atoi(value) == 1; + } else if (section == SECTION_YSF_NETWORK) { if (::strcmp(key, "Enable") == 0) - m_networkEnabled = ::atoi(value) == 1; + m_ysfNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Port") == 0) - m_networkPort = (unsigned int)::atoi(value); + m_ysfNetworkPort = (unsigned int)::atoi(value); else if (::strcmp(key, "Hosts") == 0) - m_networkHosts = value; + m_ysfNetworkHosts = value; else if (::strcmp(key, "ReloadTime") == 0) - m_networkReloadTime = (unsigned int)::atoi(value); + m_ysfNetworkReloadTime = (unsigned int)::atoi(value); else if (::strcmp(key, "ParrotAddress") == 0) - m_networkParrotAddress = value; + m_ysfNetworkParrotAddress = value; else if (::strcmp(key, "ParrotPort") == 0) - m_networkParrotPort = (unsigned int)::atoi(value); + m_ysfNetworkParrotPort = (unsigned int)::atoi(value); else if (::strcmp(key, "YSF2DMRAddress") == 0) - m_networkYSF2DMRAddress = value; + m_ysfNetworkYSF2DMRAddress = value; else if (::strcmp(key, "YSF2DMRPort") == 0) - m_networkYSF2DMRPort = (unsigned int)::atoi(value); - else if (::strcmp(key, "Startup") == 0) - m_networkStartup = value; - else if (::strcmp(key, "InactivityTimeout") == 0) - m_networkInactivityTimeout = (unsigned int)::atoi(value); - else if (::strcmp(key, "Revert") == 0) - m_networkRevert = ::atoi(value) == 1; - else if (::strcmp(key, "Debug") == 0) - m_networkDebug = ::atoi(value) == 1; + m_ysfNetworkYSF2DMRPort = (unsigned int)::atoi(value); + } else if (section == SECTION_FCS_NETWORK) { + if (::strcmp(key, "Enable") == 0) + m_fcsNetworkEnabled = ::atoi(value) == 1; + else if (::strcmp(key, "Port") == 0) + m_fcsNetworkPort = (unsigned int)::atoi(value); } } @@ -218,6 +235,11 @@ std::string CConf::getSuffix() const return m_suffix; } +unsigned int CConf::getId() const +{ + return m_id; +} + std::string CConf::getRptAddress() const { return m_rptAddress; @@ -328,62 +350,72 @@ std::string CConf::getAPRSDescription() const return m_aprsDescription; } -bool CConf::getNetworkEnabled() const +std::string CConf::getNetworkStartup() const { - return m_networkEnabled; + return m_networkStartup; } -unsigned int CConf::getNetworkPort() const +unsigned int CConf::getNetworkInactivityTimeout() const { - return m_networkPort; + return m_networkInactivityTimeout; } -std::string CConf::getNetworkHosts() const +bool CConf::getNetworkRevert() const { - return m_networkHosts; + return m_networkRevert; } -unsigned int CConf::getNetworkReloadTime() const +bool CConf::getNetworkDebug() const { - return m_networkReloadTime; + return m_networkDebug; } -std::string CConf::getNetworkParrotAddress() const +bool CConf::getYSFNetworkEnabled() const { - return m_networkParrotAddress; + return m_ysfNetworkEnabled; } -unsigned int CConf::getNetworkParrotPort() const +unsigned int CConf::getYSFNetworkPort() const { - return m_networkParrotPort; + return m_ysfNetworkPort; } -std::string CConf::getNetworkYSF2DMRAddress() const +std::string CConf::getYSFNetworkHosts() const { - return m_networkYSF2DMRAddress; + return m_ysfNetworkHosts; } -unsigned int CConf::getNetworkYSF2DMRPort() const +unsigned int CConf::getYSFNetworkReloadTime() const { - return m_networkYSF2DMRPort; + return m_ysfNetworkReloadTime; } -std::string CConf::getNetworkStartup() const +std::string CConf::getYSFNetworkParrotAddress() const { - return m_networkStartup; + return m_ysfNetworkParrotAddress; } -unsigned int CConf::getNetworkInactivityTimeout() const +unsigned int CConf::getYSFNetworkParrotPort() const { - return m_networkInactivityTimeout; + return m_ysfNetworkParrotPort; } -bool CConf::getNetworkRevert() const +std::string CConf::getYSFNetworkYSF2DMRAddress() const { - return m_networkRevert; + return m_ysfNetworkYSF2DMRAddress; } -bool CConf::getNetworkDebug() const +unsigned int CConf::getYSFNetworkYSF2DMRPort() const { - return m_networkDebug; + return m_ysfNetworkYSF2DMRPort; +} + +bool CConf::getFCSNetworkEnabled() const +{ + return m_fcsNetworkEnabled; +} + +unsigned int CConf::getFCSNetworkPort() const +{ + return m_fcsNetworkPort; } diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 3ea4c0d..092a6d5 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 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 @@ -33,6 +33,7 @@ public: // The General section std::string getCallsign() const; std::string getSuffix() const; + unsigned int getId() const; std::string getRptAddress() const; unsigned int getRptPort() const; std::string getMyAddress() const; @@ -63,23 +64,30 @@ public: std::string getAPRSDescription() const; // The Network section - bool getNetworkEnabled() const; - unsigned int getNetworkPort() const; - std::string getNetworkHosts() const; - unsigned int getNetworkReloadTime() const; - std::string getNetworkParrotAddress() const; - unsigned int getNetworkParrotPort() const; - std::string getNetworkYSF2DMRAddress() const; - unsigned int getNetworkYSF2DMRPort() const; std::string getNetworkStartup() const; unsigned int getNetworkInactivityTimeout() const; bool getNetworkRevert() const; bool getNetworkDebug() const; + // The YSF Network section + bool getYSFNetworkEnabled() const; + unsigned int getYSFNetworkPort() const; + std::string getYSFNetworkHosts() const; + unsigned int getYSFNetworkReloadTime() const; + std::string getYSFNetworkParrotAddress() const; + unsigned int getYSFNetworkParrotPort() const; + std::string getYSFNetworkYSF2DMRAddress() const; + unsigned int getYSFNetworkYSF2DMRPort() const; + + // The FCS Network section + bool getFCSNetworkEnabled() const; + unsigned int getFCSNetworkPort() const; + private: std::string m_file; std::string m_callsign; std::string m_suffix; + unsigned int m_id; std::string m_rptAddress; unsigned int m_rptPort; std::string m_myAddress; @@ -106,18 +114,22 @@ private: std::string m_aprsPassword; std::string m_aprsDescription; - bool m_networkEnabled; - unsigned int m_networkPort; - std::string m_networkHosts; - unsigned int m_networkReloadTime; - std::string m_networkParrotAddress; - unsigned int m_networkParrotPort; - std::string m_networkYSF2DMRAddress; - unsigned int m_networkYSF2DMRPort; std::string m_networkStartup; unsigned int m_networkInactivityTimeout; bool m_networkRevert; bool m_networkDebug; + + bool m_ysfNetworkEnabled; + unsigned int m_ysfNetworkPort; + std::string m_ysfNetworkHosts; + unsigned int m_ysfNetworkReloadTime; + std::string m_ysfNetworkParrotAddress; + unsigned int m_ysfNetworkParrotPort; + std::string m_ysfNetworkYSF2DMRAddress; + unsigned int m_ysfNetworkYSF2DMRPort; + + bool m_fcsNetworkEnabled; + unsigned int m_fcsNetworkPort; }; #endif diff --git a/YSFGateway/DTMF.cpp b/YSFGateway/DTMF.cpp index b1658fc..f08b2da 100644 --- a/YSFGateway/DTMF.cpp +++ b/YSFGateway/DTMF.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012,2013,2015,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2012,2013,2015,2017,2018 by Jonathan Naylor G4KLX * Copyright (C) 2011 by DV Developer Group. DJ0ABR * * This program is free software; you can redistribute it and/or modify @@ -42,6 +42,8 @@ const unsigned char DTMF_VD2_SYMD[] = { 0x11U, 0x10U, 0x20U, 0x20U, 0x11U, 0x01U const unsigned char DTMF_VD2_SYMS[] = { 0x00U, 0x23U, 0x02U, 0x02U, 0x11U, 0x10U, 0x10U, 0x01U, 0x22U, 0x62U, 0x04U }; const unsigned char DTMF_VD2_SYMH[] = { 0x00U, 0x22U, 0x00U, 0x20U, 0x11U, 0x11U, 0x10U, 0x00U, 0x22U, 0x62U, 0x04U }; +const unsigned char VD2_SILENCE[] = { 0x7BU, 0xB2U, 0x8EU, 0x43U, 0x36U, 0xE4U, 0xA2U, 0x39U, 0x78U, 0x49U, 0x33U, 0x68U, 0x33U }; + CDTMF::CDTMF() : m_data(), m_command(), @@ -56,7 +58,7 @@ CDTMF::~CDTMF() { } -WX_STATUS CDTMF::decodeVDMode2(const unsigned char* payload, bool end) +WX_STATUS CDTMF::decodeVDMode2(unsigned char* payload, bool end) { assert(payload != NULL); @@ -71,7 +73,7 @@ WX_STATUS CDTMF::decodeVDMode2(const unsigned char* payload, bool end) return WXS_NONE; } -WX_STATUS CDTMF::decodeVDMode2Slice(const unsigned char* ambe, bool end) +WX_STATUS CDTMF::decodeVDMode2Slice(unsigned char* ambe, bool end) { // DTMF begins with these byte values if (!end && (ambe[0] & DTMF_VD2_MASK[0]) == DTMF_VD2_SIG[0] && (ambe[1] & DTMF_VD2_MASK[1]) == DTMF_VD2_SIG[1] && @@ -127,6 +129,10 @@ WX_STATUS CDTMF::decodeVDMode2Slice(const unsigned char* ambe, bool end) else if (sym0 == DTMF_VD2_SYMH[0] && sym1 == DTMF_VD2_SYMH[1] && sym2 == DTMF_VD2_SYMH[2] && sym3 == DTMF_VD2_SYMH[3] && sym4 == DTMF_VD2_SYMH[4] && sym5 == DTMF_VD2_SYMH[5] && sym6 == DTMF_VD2_SYMH[6] && sym7 == DTMF_VD2_SYMH[7] && sym8 == DTMF_VD2_SYMH[8] && sym9 == DTMF_VD2_SYMH[9] && sym10 == DTMF_VD2_SYMH[10]) c = '#'; + // Blank out the DTMF tones. + if (c != ' ') + ::memcpy(ambe, VD2_SILENCE, 13U); + if (c == m_lastChar) { m_pressCount++; } else { @@ -160,21 +166,44 @@ WX_STATUS CDTMF::decodeVDMode2Slice(const unsigned char* ambe, bool end) WX_STATUS CDTMF::validate() const { - if (m_command.length() != 6U) - return WXS_NONE; - - if (m_command.at(0U) != '#') + if (m_command.empty()) return WXS_NONE; - for (unsigned int i = 1U; i <= 6U; i++) { - if (m_command.at(1U) < '0' || m_command.at(1U) > '9') - return WXS_NONE; - } + size_t length = m_command.length(); + char first = m_command.at(0U); - if (m_command == "#99999") + if (length == 1U && first == '#') { return WXS_DISCONNECT; + } else if (length == 3U && first == 'A') { + for (unsigned int i = 1U; i < 3U; i++) { + char c = m_command.at(i); + if (c < '0' || c > '9') + return WXS_NONE; + } + + return WXS_CONNECT_FCS; + } else if (length == 4U && first == 'A') { + for (unsigned int i = 1U; i < 4U; i++) { + char c = m_command.at(i); + if (c < '0' || c > '9') + return WXS_NONE; + } - return WXS_CONNECT; + return WXS_CONNECT_FCS; + } else if (length == 6U && first == '#') { + for (unsigned int i = 1U; i < 6U; i++) { + char c = m_command.at(i); + if (c < '0' || c > '9') + return WXS_NONE; + } + + if (m_command == "#99999") + return WXS_DISCONNECT; + + return WXS_CONNECT_YSF; + } + + return WXS_NONE; } std::string CDTMF::getReflector() @@ -182,6 +211,9 @@ std::string CDTMF::getReflector() std::string command = m_command; reset(); + if (command.empty()) + return ""; + return command.substr(1U); } diff --git a/YSFGateway/DTMF.h b/YSFGateway/DTMF.h index f73dfb9..8410505 100644 --- a/YSFGateway/DTMF.h +++ b/YSFGateway/DTMF.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012,2013,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2012,2013,2017,2018 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,7 +28,7 @@ public: CDTMF(); ~CDTMF(); - WX_STATUS decodeVDMode2(const unsigned char* payload, bool end); + WX_STATUS decodeVDMode2(unsigned char* payload, bool end); std::string getReflector(); @@ -42,7 +42,7 @@ private: unsigned int m_pressCount; char m_lastChar; - WX_STATUS decodeVDMode2Slice(const unsigned char* ambe, bool end); + WX_STATUS decodeVDMode2Slice(unsigned char* ambe, bool end); WX_STATUS validate() const; }; diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp new file mode 100644 index 0000000..3d2c0bf --- /dev/null +++ b/YSFGateway/FCSNetwork.cpp @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2009-2014,2016,2017,2018 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "YSFDefines.h" +#include "FCSNetwork.h" +#include "Utils.h" +#include "Log.h" + +#include +#include +#include + +const char* FCS_VERSION = "MMDVM"; + +const unsigned int BUFFER_LENGTH = 200U; + +CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug) : +m_socket(port), +m_debug(debug), +m_address(), +m_ping(NULL), +m_info(NULL), +m_reflector(), +m_print(), +m_buffer(1000U, "FCS Network Buffer"), +m_n(0U), +m_pingTimer(1000U, 0U, 800U), +m_resetTimer(1000U, 1U), +m_state(FCS_UNLINKED) +{ + m_info = new unsigned char[100U]; + ::sprintf((char*)m_info, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id); + ::memset(m_info + 43U, ' ', 57U); + + m_ping = new unsigned char[25U]; + ::sprintf((char*)m_ping, "PING%6.6s", callsign.c_str()); + ::memset(m_ping + 10U, ' ', 15U); +} + +CFCSNetwork::~CFCSNetwork() +{ + delete[] m_info; + delete[] m_ping; +} + +bool CFCSNetwork::open() +{ + LogMessage("Resolving FCS00x addresses"); + + 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"); + + LogMessage("Opening FCS network connection"); + + return m_socket.open(); +} + +void CFCSNetwork::clearDestination() +{ + m_pingTimer.stop(); + m_resetTimer.stop(); + + m_state = FCS_UNLINKED; +} + +void CFCSNetwork::write(const unsigned char* data) +{ + assert(data != NULL); + + if (m_state != FCS_LINKED) + return; + + unsigned char buffer[130U]; + ::memset(buffer + 0U, ' ', 130U); + ::memcpy(buffer + 0U, data + 35U, 120U); + ::memcpy(buffer + 121U, m_reflector.c_str(), 8U); + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Sent", buffer, 130U); + + m_socket.write(buffer, 130U, m_address, FCS_PORT); +} + +bool CFCSNetwork::writeLink(const std::string& reflector) +{ + if (m_state != FCS_LINKED) { + std::string name = reflector.substr(0U, 6U); + if (m_addresses.count(name) == 0U) { + LogError("Unknown FCS reflector - %s", name.c_str()); + return false; + } + + m_address = m_addresses[name]; + if (m_address.s_addr == INADDR_NONE) { + LogError("FCS reflector %s has no address", name.c_str()); + return false; + } + } + + m_reflector = reflector; + ::memcpy(m_ping + 10U, reflector.c_str(), 8U); + + m_print = reflector.substr(0U, 6U) + "-" + reflector.substr(6U); + + m_state = FCS_LINKING; + + m_pingTimer.start(); + + writePing(); + + return true; +} + +void CFCSNetwork::writeUnlink(unsigned int count) +{ + if (m_state != FCS_LINKED) + return; + + for (unsigned int i = 0U; i < count; i++) + m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, FCS_PORT); +} + +void CFCSNetwork::clock(unsigned int ms) +{ + m_pingTimer.clock(ms); + if (m_pingTimer.isRunning() && m_pingTimer.hasExpired()) { + writePing(); + m_pingTimer.start(); + } + + m_resetTimer.clock(ms); + if (m_resetTimer.isRunning() && m_resetTimer.hasExpired()) { + m_n = 0U; + m_resetTimer.stop(); + } + + unsigned char buffer[BUFFER_LENGTH]; + + in_addr address; + unsigned int port; + int length = m_socket.read(buffer, BUFFER_LENGTH, address, port); + if (length <= 0) + return; + + if (m_state == FCS_UNLINKED) + return; + + if (address.s_addr != m_address.s_addr || port != FCS_PORT) + return; + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Received", buffer, length); + + if (length == 7) { + if (m_state == FCS_LINKING) + LogMessage("Linked to %s", m_print.c_str()); + m_state = FCS_LINKED; + writeInfo(); + } + + if (length == 10 && m_state == FCS_LINKING) { + LogMessage("Linked to %s", m_print.c_str()); + m_state = FCS_LINKED; + writeInfo(); + } + + if (length == 7 || length == 10 || length == 130) { + unsigned char len = length; + m_buffer.addData(&len, 1U); + m_buffer.addData(buffer, len); + } +} + +unsigned int CFCSNetwork::read(unsigned char* data) +{ + assert(data != NULL); + + if (m_buffer.isEmpty()) + return 0U; + + unsigned char len = 0U; + m_buffer.getData(&len, 1U); + + // Pass pings up to the gateway to reset the lost timer. + if (len != 130U) { + m_buffer.getData(data, len); + + ::memset(data + 0U, ' ', 14U); + ::memcpy(data + 0U, "YSFP", 4U); + ::memcpy(data + 4U, m_print.c_str(), 8U); + + return 14U; + } + + m_resetTimer.start(); + + unsigned char buffer[130U]; + m_buffer.getData(buffer, len); + + ::memset(data + 0U, ' ', 35U); + ::memcpy(data + 0U, "YSFD", 4U); + ::memcpy(data + 35U, buffer, 120U); + + // Put the reflector name as the via callsign. + ::memcpy(data + 4U, m_print.c_str(), 9U); + + data[34U] = m_n; + m_n += 2U; + + return 155U; +} + +void CFCSNetwork::close() +{ + m_socket.close(); + + LogMessage("Closing FCS network connection"); +} + +void CFCSNetwork::writeInfo() +{ + if (m_state != FCS_LINKED) + return; + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Sent", m_info, 100U); + + m_socket.write(m_info, 100U, m_address, FCS_PORT); +} + +void CFCSNetwork::writePing() +{ + if (m_state == FCS_UNLINKED) + return; + + if (m_debug) + CUtils::dump(1U, "FCS Network Data Sent", m_ping, 25U); + + m_socket.write(m_ping, 25U, m_address, FCS_PORT); +} diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h new file mode 100644 index 0000000..0dd0d18 --- /dev/null +++ b/YSFGateway/FCSNetwork.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2009-2014,2016,2017,2018 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef FCSNetwork_H +#define FCSNetwork_H + +#include "YSFDefines.h" +#include "UDPSocket.h" +#include "RingBuffer.h" +#include "Timer.h" + +#include +#include +#include + +enum FCS_STATE { + FCS_UNLINKED, + FCS_LINKING, + FCS_LINKED +}; + +class CFCSNetwork { +public: + CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug); + ~CFCSNetwork(); + + bool open(); + + void clearDestination(); + + void write(const unsigned char* data); + + bool writeLink(const std::string& reflector); + + void writeUnlink(unsigned int count = 1U); + + unsigned int read(unsigned char* data); + + void clock(unsigned int ms); + + void close(); + +private: + CUDPSocket m_socket; + bool m_debug; + in_addr m_address; + unsigned char* m_ping; + unsigned char* m_info; + std::string m_reflector; + std::string m_print; + CRingBuffer m_buffer; + std::map m_addresses; + unsigned char m_n; + CTimer m_pingTimer; + CTimer m_resetTimer; + FCS_STATE m_state; + + void writeInfo(); + void writePing(); +}; + +#endif diff --git a/YSFGateway/Makefile b/YSFGateway/Makefile index 5646b0c..ad68fce 100644 --- a/YSFGateway/Makefile +++ b/YSFGateway/Makefile @@ -4,8 +4,8 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lm -lpthread LDFLAGS = -g -OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o Network.o Reflectors.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ - UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFPayload.o +OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o FCSNetwork.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ + UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o all: YSFGateway diff --git a/YSFGateway/Makefile.Solaris b/YSFGateway/Makefile.Solaris index 83461e4..dfd7c11 100644 --- a/YSFGateway/Makefile.Solaris +++ b/YSFGateway/Makefile.Solaris @@ -4,8 +4,8 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lm -lpthread -lsocket LDFLAGS = -g -OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o Golay24128.o GPS.o Log.o Network.o Reflectors.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ - UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFPayload.o +OBJECTS = APRSWriterThread.o APRSWriter.o Conf.o CRC.o DTMF.o FCSNetwork.o Golay24128.o GPS.o Log.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o \ + UDPSocket.o Utils.o WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFNetwork.o YSFPayload.o YSFReflectors.o all: YSFGateway diff --git a/YSFGateway/Version.h b/YSFGateway/Version.h index b6885be..f3baaa8 100644 --- a/YSFGateway/Version.h +++ b/YSFGateway/Version.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 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 @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20170719"; +const char* VERSION = "20180228"; #endif diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index ec362bb..db0aede 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 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 @@ -42,11 +42,11 @@ const unsigned char DEFAULT_FICH[] = {0x20U, 0x00U, 0x01U, 0x00U}; const unsigned char NET_HEADER[] = "YSFD ALL "; -CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CNetwork* network, const std::string& hostsFile, unsigned int reloadTime) : +CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, CYSFReflectors& reflectors) : m_callsign(callsign), m_node(), m_network(network), -m_reflectors(hostsFile, reloadTime), +m_reflectors(reflectors), m_reflector(NULL), m_id(), m_name(), @@ -159,10 +159,6 @@ void CWiresX::setYSF2DMR(const std::string& address, unsigned int port) bool CWiresX::start() { - bool ret = m_reflectors.load(); - if (!ret) - return false; - m_reflectors.reload(); return true; @@ -239,11 +235,9 @@ CYSFReflector* CWiresX::getReflector() const return m_reflector; } -CYSFReflector* CWiresX::getReflector(const std::string& id) +void CWiresX::setReflector(CYSFReflector* reflector) { - m_reflector = m_reflectors.find(id); - - return m_reflector; + m_reflector = reflector; } void CWiresX::processDX(const unsigned char* source) @@ -287,14 +281,14 @@ WX_STATUS CWiresX::processConnect(const unsigned char* source, const unsigned ch std::string id = std::string((char*)data, 5U); - m_reflector = m_reflectors.find(id); + m_reflector = m_reflectors.findById(id); if (m_reflector == NULL) return WXS_NONE; m_status = WXSI_CONNECT; m_timer.start(); - return WXS_CONNECT; + return WXS_CONNECT_YSF; } void CWiresX::processConnect(CYSFReflector* reflector) diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index ba82bd7..d979147 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 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 @@ -19,15 +19,16 @@ #if !defined(WIRESX_H) #define WIRESX_H -#include "Reflectors.h" -#include "Network.h" +#include "YSFReflectors.h" +#include "YSFNetwork.h" #include "Timer.h" #include enum WX_STATUS { WXS_NONE, - WXS_CONNECT, + WXS_CONNECT_YSF, + WXS_CONNECT_FCS, WXS_DISCONNECT }; @@ -42,7 +43,7 @@ enum WXSI_STATUS { class CWiresX { public: - CWiresX(const std::string& callsign, const std::string& suffix, CNetwork* network, const std::string& hostsFile, unsigned int reloadTime); + CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, CYSFReflectors& reflectors); ~CWiresX(); void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency); @@ -54,7 +55,7 @@ public: WX_STATUS process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); CYSFReflector* getReflector() const; - CYSFReflector* getReflector(const std::string& id); + void setReflector(CYSFReflector* reflector); void processConnect(CYSFReflector* reflector); void processDisconnect(const unsigned char* source = NULL); @@ -62,25 +63,25 @@ public: void clock(unsigned int ms); private: - std::string m_callsign; - std::string m_node; - CNetwork* m_network; - CReflectors m_reflectors; - CYSFReflector* m_reflector; - std::string m_id; - std::string m_name; - unsigned char* m_command; - unsigned int m_txFrequency; - unsigned int m_rxFrequency; - CTimer m_timer; - unsigned char m_seqNo; - unsigned char* m_header; - unsigned char* m_csd1; - unsigned char* m_csd2; - unsigned char* m_csd3; - WXSI_STATUS m_status; - unsigned int m_start; - std::string m_search; + std::string m_callsign; + std::string m_node; + CYSFNetwork* m_network; + CYSFReflectors& m_reflectors; + CYSFReflector* m_reflector; + std::string m_id; + std::string m_name; + unsigned char* m_command; + unsigned int m_txFrequency; + unsigned int m_rxFrequency; + CTimer m_timer; + unsigned char m_seqNo; + unsigned char* m_header; + unsigned char* m_csd1; + unsigned char* m_csd2; + unsigned char* m_csd3; + WXSI_STATUS m_status; + unsigned int m_start; + std::string m_search; WX_STATUS processConnect(const unsigned char* source, const unsigned char* data); void processDX(const unsigned char* source); diff --git a/YSFGateway/YSFDefines.h b/YSFGateway/YSFDefines.h index 2e75625..b2aefc6 100644 --- a/YSFGateway/YSFDefines.h +++ b/YSFGateway/YSFDefines.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 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 @@ -47,4 +47,6 @@ const unsigned char YSF_CM_INDIVIDUAL = 0x03U; const unsigned char YSF_MR_NOT_BUSY = 0x01U; const unsigned char YSF_MR_BUSY = 0x02U; +const unsigned int FCS_PORT = 62500U; + #endif diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 8f39137..3cc0384 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 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 @@ -17,7 +17,6 @@ */ #include "YSFGateway.h" -#include "Reflectors.h" #include "UDPSocket.h" #include "StopWatch.h" #include "Version.h" @@ -46,6 +45,7 @@ const char* DEFAULT_INI_FILE = "/etc/YSFGateway.ini"; #include #include #include +#include int main(int argc, char** argv) { @@ -79,11 +79,17 @@ m_callsign(), m_suffix(), m_conf(configFile), m_gps(NULL), +m_reflectors(NULL), m_wiresX(NULL), -m_dtmf(NULL), -m_netNetwork(NULL), -m_linked(false), -m_exclude(false) +m_dtmf(), +m_ysfNetwork(NULL), +m_fcsNetwork(NULL), +m_linkType(LINK_NONE), +m_current(), +m_startup(), +m_exclude(false), +m_inactivityTimer(1000U), +m_lostTimer(1000U, 120U) { } @@ -115,7 +121,8 @@ int CYSFGateway::run() if (pid == -1) { ::LogWarning("Couldn't fork() , exiting"); return -1; - } else if (pid != 0) + } + else if (pid != 0) exit(EXIT_SUCCESS); // Create new session and process group @@ -174,8 +181,8 @@ int CYSFGateway::run() std::string myAddress = m_conf.getMyAddress(); unsigned int myPort = m_conf.getMyPort(); - CNetwork rptNetwork(myAddress, myPort, m_callsign, debug); - rptNetwork.setDestination(rptAddress, rptPort); + CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug); + rptNetwork.setDestination("MMDVM", rptAddress, rptPort); ret = rptNetwork.open(); if (!ret) { @@ -184,79 +191,60 @@ int CYSFGateway::run() return 1; } - unsigned int netPort = m_conf.getNetworkPort(); + bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled(); + if (ysfNetworkEnabled) { + unsigned int ysfPort = m_conf.getYSFNetworkPort(); - m_netNetwork = new CNetwork(netPort, m_callsign, debug); - ret = m_netNetwork->open(); - if (!ret) { - ::LogError("Cannot open the reflector network port"); - ::LogFinalise(); - return 1; + m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug); + ret = m_ysfNetwork->open(); + if (!ret) { + ::LogError("Cannot open the YSF reflector network port"); + ::LogFinalise(); + return 1; + } } - CTimer inactivityTimer(1000U, m_conf.getNetworkInactivityTimeout() * 60U); - CTimer lostTimer(1000U, 120U); - CTimer pollTimer(1000U, 5U); - - bool revert = m_conf.getNetworkRevert(); - std::string startup = m_conf.getNetworkStartup(); - - bool networkEnabled = m_conf.getNetworkEnabled(); - if (networkEnabled) { - std::string fileName = m_conf.getNetworkHosts(); - unsigned int reloadTime = m_conf.getNetworkReloadTime(); - - m_wiresX = new CWiresX(m_callsign, m_suffix, &rptNetwork, fileName, reloadTime); - m_dtmf = new CDTMF; - - std::string name = m_conf.getName(); + bool fcsNetworkEnabled = m_conf.getFCSNetworkEnabled(); + if (fcsNetworkEnabled) { unsigned int txFrequency = m_conf.getTxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency(); + std::string locator = calculateLocator(); + unsigned int id = m_conf.getId(); - m_wiresX->setInfo(name, txFrequency, rxFrequency); + unsigned int fcsPort = m_conf.getFCSNetworkPort(); - std::string address = m_conf.getNetworkParrotAddress(); - unsigned int port = m_conf.getNetworkParrotPort(); - - if (port > 0U) - m_wiresX->setParrot(address, port); - - address = m_conf.getNetworkYSF2DMRAddress(); - port = m_conf.getNetworkYSF2DMRPort(); + m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, rxFrequency, txFrequency, locator, id, debug); + ret = m_fcsNetwork->open(); + if (!ret) { + ::LogError("Cannot open the FCS reflector network port"); + ::LogFinalise(); + return 1; + } + } - if (port > 0U) - m_wiresX->setYSF2DMR(address, port); + m_inactivityTimer.setTimeout(m_conf.getNetworkInactivityTimeout() * 60U); - m_wiresX->start(); + std::string fileName = m_conf.getYSFNetworkHosts(); + unsigned int reloadTime = m_conf.getYSFNetworkReloadTime(); - if (!startup.empty()) { - CYSFReflector* reflector = m_wiresX->getReflector(startup); - if (reflector != NULL) { - LogMessage("Automatic connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); + m_reflectors = new CYSFReflectors(fileName, reloadTime); + m_reflectors->load(); + m_reflectors->reload(); - m_netNetwork->setDestination(reflector->m_address, reflector->m_port); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); + createWiresX(&rptNetwork); - if (!revert) - inactivityTimer.start(); + createGPS(); - lostTimer.start(); - pollTimer.start(); + m_startup = m_conf.getNetworkStartup(); + bool revert = m_conf.getNetworkRevert(); - m_linked = true; - } - } - } + startupLinking(); CStopWatch stopWatch; stopWatch.start(); LogMessage("Starting YSFGateway-%s", VERSION); - createGPS(); - for (;;) { unsigned char buffer[200U]; @@ -272,133 +260,56 @@ int CYSFGateway::run() // Don't send out control data m_exclude = (dt == YSF_DT_DATA_FR_MODE); - if (m_wiresX != NULL) { - WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); - switch (status) { - case WXS_CONNECT: { - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - - CYSFReflector* reflector = m_wiresX->getReflector(); - LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); - - m_netNetwork->setDestination(reflector->m_address, reflector->m_port); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - - inactivityTimer.start(); - lostTimer.start(); - pollTimer.start(); - - m_linked = true; - } - break; - case WXS_DISCONNECT: - LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); - - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->clearDestination(); - - inactivityTimer.stop(); - lostTimer.stop(); - pollTimer.stop(); - - m_linked = false; - break; - default: - break; - } - - status = WXS_NONE; - switch (dt) { - case YSF_DT_VD_MODE2: - status = m_dtmf->decodeVDMode2(buffer + 35U, (buffer[34U] & 0x01U) == 0x01U); - break; - default: - break; - } - - switch (status) { - case WXS_CONNECT: { - std::string id = m_dtmf->getReflector(); - CYSFReflector* reflector = m_wiresX->getReflector(id); - if (reflector != NULL) { - m_wiresX->processConnect(reflector); - - if (m_linked) { - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - } - - LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); + processWiresX(buffer, fi, dt, fn, ft); - m_netNetwork->setDestination(reflector->m_address, reflector->m_port); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - - inactivityTimer.start(); - lostTimer.start(); - pollTimer.start(); - - m_linked = true; - } - } - break; - case WXS_DISCONNECT: - if (m_linked) { - m_wiresX->processDisconnect(); - - LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); - - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->clearDestination(); - - inactivityTimer.stop(); - lostTimer.stop(); - pollTimer.stop(); - - m_linked = false; - } - break; - default: - break; - } - } + processDTMF(buffer, dt); if (m_gps != NULL) m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft); } - if (networkEnabled && m_linked && !m_exclude) { - m_netNetwork->write(buffer); + if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && !m_exclude) { + m_ysfNetwork->write(buffer); if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) - inactivityTimer.start(); + m_inactivityTimer.start(); + } + + if (m_fcsNetwork != NULL && m_linkType == LINK_FCS && !m_exclude) { + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) { + m_fcsNetwork->write(buffer); + m_inactivityTimer.start(); + } } if ((buffer[34U] & 0x01U) == 0x01U) { if (m_gps != NULL) m_gps->reset(); - if (m_dtmf != NULL) - m_dtmf->reset(); + m_dtmf.reset(); m_exclude = false; } } - while (m_netNetwork->read(buffer) > 0U) { - if (networkEnabled && m_linked) { - // Only pass through YSF data packets - if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) - rptNetwork.write(buffer); + if (m_ysfNetwork != NULL) { + while (m_ysfNetwork->read(buffer) > 0U) { + if (m_linkType == LINK_YSF) { + // Only pass through YSF data packets + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + rptNetwork.write(buffer); + + m_lostTimer.start(); + } + } + } + + if (m_fcsNetwork != NULL) { + while (m_fcsNetwork->read(buffer) > 0U) { + if (m_linkType == LINK_FCS) { + // Only pass through YSF data packets + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + rptNetwork.write(buffer); - lostTimer.start(); + m_lostTimer.start(); + } } } @@ -406,76 +317,76 @@ int CYSFGateway::run() stopWatch.start(); rptNetwork.clock(ms); - m_netNetwork->clock(ms); + if (m_ysfNetwork != NULL) + m_ysfNetwork->clock(ms); + if (m_fcsNetwork != NULL) + m_fcsNetwork->clock(ms); if (m_gps != NULL) m_gps->clock(ms); - if (m_wiresX != NULL) - m_wiresX->clock(ms); - - inactivityTimer.clock(ms); - if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) { - if (m_linked) { - CYSFReflector* reflector = NULL; - if (revert && !startup.empty() && m_wiresX != NULL) - reflector = m_wiresX->getReflector(startup); + m_wiresX->clock(ms); - if (reflector != NULL) { - LogMessage("Reverting connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); - - m_wiresX->processConnect(reflector); + m_inactivityTimer.clock(ms); + if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) { + if (revert) { + if (m_current != m_startup) { + if (m_linkType == LINK_YSF) { + m_wiresX->processDisconnect(); + m_ysfNetwork->writeUnlink(3U); + m_ysfNetwork->clearDestination(); + } - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); + if (m_linkType == LINK_FCS) { + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); + } - m_netNetwork->setDestination(reflector->m_address, reflector->m_port); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); - m_netNetwork->writePoll(); + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; - lostTimer.start(); - pollTimer.start(); + startupLinking(); } else { + m_inactivityTimer.start(); + } + } else { + if (m_linkType == LINK_YSF) { LogMessage("Disconnecting due to inactivity"); + m_wiresX->processDisconnect(); + m_ysfNetwork->writeUnlink(3U); + m_ysfNetwork->clearDestination(); + } - if (m_wiresX != NULL) - m_wiresX->processDisconnect(); - - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->writeUnlink(); - m_netNetwork->clearDestination(); - - lostTimer.stop(); - pollTimer.stop(); - - m_linked = false; + if (m_linkType == LINK_FCS) { + LogMessage("Disconnecting due to inactivity"); + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); } - } - inactivityTimer.stop(); + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + } } - lostTimer.clock(ms); - if (lostTimer.isRunning() && lostTimer.hasExpired()) { - LogWarning("Link has failed, polls lost"); - - if (m_wiresX != NULL) + m_lostTimer.clock(ms); + if (m_lostTimer.isRunning() && m_lostTimer.hasExpired()) { + if (m_linkType == LINK_YSF) { + LogWarning("Link has failed, polls lost"); m_wiresX->processDisconnect(); + m_ysfNetwork->clearDestination(); + } - m_netNetwork->clearDestination(); - - inactivityTimer.stop(); - lostTimer.stop(); - pollTimer.stop(); - - m_linked = false; - } + if (m_fcsNetwork != NULL) { + LogWarning("Link has failed, polls lost"); + m_fcsNetwork->clearDestination(); + } - pollTimer.clock(ms); - if (pollTimer.isRunning() && pollTimer.hasExpired()) { - m_netNetwork->writePoll(); - pollTimer.start(); + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; } if (ms < 5U) @@ -483,16 +394,23 @@ int CYSFGateway::run() } rptNetwork.close(); - m_netNetwork->close(); if (m_gps != NULL) { m_gps->close(); delete m_gps; } - delete m_netNetwork; + if (m_ysfNetwork != NULL) { + m_ysfNetwork->close(); + delete m_ysfNetwork; + } + + if (m_fcsNetwork != NULL) { + m_fcsNetwork->close(); + delete m_fcsNetwork; + } + delete m_wiresX; - delete m_dtmf; ::LogFinalise(); @@ -525,3 +443,289 @@ void CYSFGateway::createGPS() m_gps = NULL; } } + +void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork) +{ + assert(rptNetwork != NULL); + + m_wiresX = new CWiresX(m_callsign, m_suffix, rptNetwork, *m_reflectors); + + std::string name = m_conf.getName(); + + unsigned int txFrequency = m_conf.getTxFrequency(); + unsigned int rxFrequency = m_conf.getRxFrequency(); + m_wiresX->setInfo(name, txFrequency, rxFrequency); + + std::string address = m_conf.getYSFNetworkParrotAddress(); + unsigned int port = m_conf.getYSFNetworkParrotPort(); + + if (port > 0U) + m_wiresX->setParrot(address, port); + + address = m_conf.getYSFNetworkYSF2DMRAddress(); + port = m_conf.getYSFNetworkYSF2DMRPort(); + + if (port > 0U) + m_wiresX->setYSF2DMR(address, port); + + m_wiresX->start(); +} + +void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft) +{ + assert(buffer != NULL); + + WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); + switch (status) { + case WXS_CONNECT_YSF: { + if (m_linkType == LINK_YSF) + m_ysfNetwork->writeUnlink(3U); + + if (m_linkType == LINK_FCS) { + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); + } + + CYSFReflector* reflector = m_wiresX->getReflector(); + LogMessage("Connect to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); + + m_ysfNetwork->setDestination(reflector->m_name, reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(3U); + + m_current = reflector->m_id; + m_inactivityTimer.start(); + m_lostTimer.start(); + m_linkType = LINK_YSF; + } + break; + case WXS_DISCONNECT: + if (m_linkType == LINK_YSF) { + LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); + + m_ysfNetwork->writeUnlink(3U); + m_ysfNetwork->clearDestination(); + + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + } + if (m_linkType == LINK_FCS) { + LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); + + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); + + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + } + break; + default: + break; + } +} + +void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt) +{ + assert(buffer != NULL); + + WX_STATUS status = WXS_NONE; + switch (dt) { + case YSF_DT_VD_MODE2: + status = m_dtmf.decodeVDMode2(buffer + 35U, (buffer[34U] & 0x01U) == 0x01U); + break; + default: + break; + } + + switch (status) { + case WXS_CONNECT_YSF: { + std::string id = m_dtmf.getReflector(); + CYSFReflector* reflector = m_reflectors->findById(id); + if (reflector != NULL) { + m_wiresX->processConnect(reflector); + + if (m_linkType == LINK_YSF) + m_ysfNetwork->writeUnlink(3U); + + if (m_linkType == LINK_FCS) { + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); + } + + LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); + + m_ysfNetwork->setDestination(reflector->m_name, reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(3U); + + m_current = id; + m_inactivityTimer.start(); + m_lostTimer.start(); + m_linkType = LINK_YSF; + } + } + break; + case WXS_CONNECT_FCS: { + std::string raw = m_dtmf.getReflector(); + std::string id = "FCS00"; + if (raw.length() == 2U) { + id += raw.at(0U) + std::string("0") + raw.at(1U); + } else if (raw.length() == 3U) { + id += raw; + } else { + LogWarning("Nonsense from the DTMF decoder - \"%s\"", raw.c_str()); + return; + } + + if (m_linkType == LINK_YSF) { + m_wiresX->processDisconnect(); + m_ysfNetwork->writeUnlink(3U); + m_ysfNetwork->clearDestination(); + } + if (m_linkType == LINK_FCS) + m_fcsNetwork->writeUnlink(3U); + + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + + LogMessage("Connect via DTMF to %s has been requested by %10.10s", id.c_str(), buffer + 14U); + + bool ok = m_fcsNetwork->writeLink(id); + if (ok) { + m_current = id; + m_inactivityTimer.start(); + m_lostTimer.start(); + m_linkType = LINK_FCS; + } else { + LogMessage("Unknown reflector - %s", id.c_str()); + } + } + break; + case WXS_DISCONNECT: + if (m_linkType == LINK_YSF) { + m_wiresX->processDisconnect(); + + LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); + + m_ysfNetwork->writeUnlink(3U); + m_ysfNetwork->clearDestination(); + + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + } + if (m_linkType == LINK_FCS) { + LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U); + + m_fcsNetwork->writeUnlink(3U); + m_fcsNetwork->clearDestination(); + + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + } + break; + default: + break; + } +} + +std::string CYSFGateway::calculateLocator() +{ + std::string locator; + + float latitude = m_conf.getLatitude(); + float longitude = m_conf.getLongitude(); + + if (latitude < -90.0F || latitude > 90.0F) + return "AA00AA"; + + if (longitude < -360.0F || longitude > 360.0F) + return "AA00AA"; + + latitude += 90.0F; + + if (longitude > 180.0F) + longitude -= 360.0F; + + if (longitude < -180.0F) + longitude += 360.0F; + + longitude += 180.0F; + + float lon = ::floor(longitude / 20.0F); + float lat = ::floor(latitude / 10.0F); + + locator += 'A' + (unsigned int)lon; + locator += 'A' + (unsigned int)lat; + + longitude -= lon * 20.0F; + latitude -= lat * 10.0F; + + lon = ::floor(longitude / 2.0F); + lat = ::floor(latitude / 1.0F); + + locator += '0' + (unsigned int)lon; + locator += '0' + (unsigned int)lat; + + longitude -= lon * 2.0F; + latitude -= lat * 1.0F; + + lon = ::floor(longitude / (2.0F / 24.0F)); + lat = ::floor(latitude / (1.0F / 24.0F)); + + locator += 'A' + (unsigned int)lon; + locator += 'A' + (unsigned int)lat; + + return locator; +} + +void CYSFGateway::startupLinking() +{ + if (!m_startup.empty()) { + if (m_startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) { + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + + bool ok = m_fcsNetwork->writeLink(m_startup); + if (ok) { + LogMessage("Automatic (re-)connection to %s", m_startup.c_str()); + + m_current = m_startup; + m_inactivityTimer.start(); + m_lostTimer.start(); + m_linkType = LINK_FCS; + } else { + LogMessage("Unknown reflector - %s", m_startup.c_str()); + } + } else if (m_ysfNetwork != NULL) { + m_current.clear(); + m_inactivityTimer.stop(); + m_lostTimer.stop(); + m_linkType = LINK_NONE; + + CYSFReflector* reflector = m_reflectors->findByName(m_startup); + if (reflector != NULL) { + LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); + + m_wiresX->setReflector(reflector); + + m_ysfNetwork->setDestination(reflector->m_name, reflector->m_address, reflector->m_port); + m_ysfNetwork->writePoll(3U); + + m_current = m_startup; + m_inactivityTimer.start(); + m_lostTimer.start(); + m_linkType = LINK_YSF; + } + } + } +} diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index ca7ee94..238277c 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 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 @@ -19,14 +19,23 @@ #if !defined(YSFGateway_H) #define YSFGateway_H -#include "Network.h" +#include "YSFNetwork.h" +#include "YSFReflectors.h" +#include "FCSNetwork.h" #include "WiresX.h" +#include "Timer.h" #include "Conf.h" #include "DTMF.h" #include "GPS.h" #include +enum LINK_TYPE { + LINK_NONE, + LINK_YSF, + LINK_FCS +}; + class CYSFGateway { public: @@ -36,16 +45,27 @@ public: int run(); private: - std::string m_callsign; - std::string m_suffix; - CConf m_conf; - CGPS* m_gps; - CWiresX* m_wiresX; - CDTMF* m_dtmf; - CNetwork* m_netNetwork; - bool m_linked; - bool m_exclude; + std::string m_callsign; + std::string m_suffix; + CConf m_conf; + CGPS* m_gps; + CYSFReflectors* m_reflectors; + CWiresX* m_wiresX; + CDTMF m_dtmf; + CYSFNetwork* m_ysfNetwork; + CFCSNetwork* m_fcsNetwork; + LINK_TYPE m_linkType; + std::string m_current; + std::string m_startup; + bool m_exclude; + CTimer m_inactivityTimer; + CTimer m_lostTimer; + void startupLinking(); + std::string calculateLocator(); + void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); + void processDTMF(unsigned char* buffer, unsigned char dt); + void createWiresX(CYSFNetwork* rptNetwork); void createGPS(); }; diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index f8ccab5..5ecddd3 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -2,6 +2,7 @@ Callsign=G9BF Suffix=RPT # Suffix=ND +Id=1234567 RptAddress=127.0.0.1 RptPort=3200 LocalAddress=127.0.0.1 @@ -34,6 +35,13 @@ Password=9999 Description=APRS Description [Network] +# Startup=FCS00120 +# Startup=Alabama-Link +InactivityTimeout=10 +Revert=0 +Debug=0 + +[YSF Network] Enable=1 Port=42000 Hosts=./YSFHosts.txt @@ -42,7 +50,7 @@ ParrotAddress=127.0.0.1 ParrotPort=42012 YSF2DMRAddress=127.0.0.1 YSF2DMRPort=42013 -# Startup= -InactivityTimeout=10 -# Revert=0 -Debug=0 + +[FCS Network] +Enable=1 +Port=42001 diff --git a/YSFGateway/YSFGateway.vcxproj b/YSFGateway/YSFGateway.vcxproj index 386e32f..df351b7 100644 --- a/YSFGateway/YSFGateway.vcxproj +++ b/YSFGateway/YSFGateway.vcxproj @@ -151,11 +151,10 @@ + - - @@ -170,7 +169,9 @@ + + @@ -178,11 +179,10 @@ + - - @@ -194,7 +194,9 @@ + + diff --git a/YSFGateway/YSFGateway.vcxproj.filters b/YSFGateway/YSFGateway.vcxproj.filters index 20053c3..246f020 100644 --- a/YSFGateway/YSFGateway.vcxproj.filters +++ b/YSFGateway/YSFGateway.vcxproj.filters @@ -11,9 +11,6 @@ - - Header Files - Header Files @@ -74,9 +71,6 @@ Header Files - - Header Files - Header Files @@ -86,11 +80,17 @@ Header Files + + Header Files + + + Header Files + + + Header Files + - - Source Files - Source Files @@ -142,9 +142,6 @@ Source Files - - Source Files - Source Files @@ -154,5 +151,14 @@ Source Files + + Source Files + + + Source Files + + + Source Files + \ No newline at end of file diff --git a/YSFGateway/YSFHosts.txt b/YSFGateway/YSFHosts.txt index abd17e8..bcfb4d5 100644 --- a/YSFGateway/YSFHosts.txt +++ b/YSFGateway/YSFHosts.txt @@ -1,165 +1,195 @@ -65702;0 OE-Austria;Official;94.199.172.148;42000;001 -88236;1004 DMR;DRM C4FM CROSS;210.178.113.173;42000;000 -74652;119-YSF;TG45004 XLX170;125.129.207.86;42000;002 -89803;A.O.T. Roma;OndaTelematica;31.14.140.230;42000;000 -02034;Alabama-Link;Alabama-Link;199.119.98.174;42000;029 -64230;America-RC;YSF-TO-WIRES-X;71.209.204.22;42000;006 -38654;ARGENTINA;C4FM Team;212.237.3.87;42000;005 -59330;ARRGUS Array;Florida USA;96.94.7.200;42000;000 -42586;ARRGUS_ArrayN;Back up server;64.137.194.85;42000;000 -25223;AT Austria OE1;OE1PHS;77.117.224.174;42000;002 -00396;AT Austria OE3;OE3AAS;77.118.186.2;42100;001 -55693;AT C4FM Austria;YSF;89.185.97.38;42000;008 -04201;AU YSF001;1st WW YSF;104.167.114.230;42000;012 -93760;BE YSF-Vlaandere;C4FM Vlaandere;81.95.126.168;42000;004 -79520;BE YSF-Wallonie;C4FM Wallon;51.255.193.63;42000;004 -67661;BG Bulgaria;Sysop: LZ1LCD;95.43.222.149;42000;000 -47573;BM-EA-TG914;BM-EA-TG914;104.223.70.166;42000;003 -14341;BM-TG-208;BrMstr TG208;51.254.126.212;42000;002 -30745;BM-TG-2080;BrMstr TG2080;51.254.126.212;42080;001 -00872;BM-TG-20820;BrMstr TG20820;51.254.126.212;42020;001 -52846;BM-TG-20859;BrMstr TG20859;51.254.126.212;42059;002 -39552;BM-TG-2087;BrMstr TG2087;51.254.126.212;42007;001 -93206;BM-TG-2088;BrMstr TG2088;51.254.126.212;42008;001 -35402;BM-TG-2089;BrMstr TG2089;51.254.126.212;42009;001 -36096;BR YSF724;C4FM - DV Braz;66.55.64.14;42000;002 -85044;C4FM-SEOUL;TG45004 XLX170;121.162.91.45;42000;004 -77353;CA Canada;C4FM Ontario;144.217.241.23;42100;006 -49473;CA QUEBEC;QC FR Fusion;64.34.60.44;42000;000 -52796;CH JOTA;Jota CH;157.161.57.65;42001;000 -59050;CL CE3FCM;ysfreflector;190.161.179.169;42000;000 -80337;CN China #1;C4FM YSF;120.234.41.144;42000;008 -82442;CN China #2;C4FM Guangzhou;218.19.147.38;42000;000 -86319;CN China #3;C4FM;123.58.6.137;42002;026 -30490;CO 4 KILO MIKE;Antioquia;190.159.68.105;43000;000 -04523;CT CATALANA;C4FM Catalunya;85.214.119.76;42000;000 -30549;CT WIRESCAT;C4FM Catalunya;85.214.119.76;42001;005 -26541;CZ Czech;TG2300 DCS019V;80.250.3.114;42000;008 -58770;CZ YSF Praha;YSF CZ;185.32.183.148;42000;000 -80861;DE DL-NORD;AFu-Nord.de;5.45.96.68;42000;000 -54919;DE DL-NORDWEST;Nordwest-DL;91.12.55.157;42000;007 -62829;DE Germany;TG26208;213.202.229.15;42000;031 -10322;DE Germany2;no bridge;213.202.229.15;42001;000 -92469;DE Hessen;SysOP:DL5RFK;193.70.38.68;42000;001 -74154;DE PEGASUS;dl0bza.de;78.46.11.65;42000;014 -20548;DE PEGASUS2;dl0bza.de;78.46.11.65;42001;000 -55966;DE Thueringen;Thueringen;37.26.200.222;42000;001 -94179;Digiland;Italia;212.227.203.37;42000;000 -68785;Digiland_2;Italia;185.206.147.131;42000;000 -68899;Digiland_3;Italia;85.217.170.178;42000;000 -00561;DVSwitch NA;North America;44.103.32.18;42000;000 -94533;EA Distrito 1;Wires X Spain;104.223.72.8;42000;000 -42493;EA Distrito 2;EDT;185.47.129.230;42000;002 -42493;EA Distrito 2;EDT;185.47.129.230;42000;002 -48495;EA Distrito 3;Wires X Spain;89.38.150.252;42000;000 -62980;EA Distrito 4;REM SPAIN;212.237.0.67;42000;001 -39908;EA Distrito 5;YSF EALINK;216.86.147.198;42000;000 -58314;EA Distrito 7;RC Veleta;212.237.11.53;42000;001 -31236;EA DMR+;DMR+ 4370;198.96.90.144;42000;000 -37172;EA Sevilla;Prov Sevilla;204.44.93.190;42000;003 -01439;EMCOM SPAIN;Emergency;212.237.17.133;42000;000 -32027;ES ADER;ASSOCIACIO;80.211.226.198;42000;003 -98529;ES ED2ZAE;Multiporpouse;94.177.237.192;42000;001 -15642;ES REM SPAIN;REM YSF REF;95.39.166.7;42000;000 -60318;ES Wires X;WIRES X SPAIN;80.211.236.189;42000;015 -62659;ES YSF214;C4FM Net;89.36.214.120;42000;000 -08054;FON-Gateway;AllModes-GW;185.109.201.81;42000;001 -60786;FR F1ZLJ (95);Val dOise-ARAM;82.236.81.19;42000;002 -86886;FR Room-ZIT;Room F1ZIT;151.80.143.185;42002;008 -39510;FR wiresxfrance;Wires-X-France;151.80.143.185;42000;000 -83665;FR YSF-Alpes;Rhone-Alpes;217.182.66.229;42000;000 -60284;FR YSF-Alsace;ALS(F) ROOM;91.121.136.94;42000;002 -19531;FR YSF-Bretagne;Bretagne;78.206.208.208;42000;000 -13844;FR YSF-Cappelle;YSF Room F1ZKY;92.188.0.108;42000;002 -58617;FR YSF-France;Fusion France;87.98.132.205;42000;023 -91713;FR YSF-Limouzi;C4FM Limousin;88.174.140.210;42000;000 -46353;FR YSF-Nord;Nord;79.137.74.24;42000;003 -33751;FUSION-ITALY;Italy YSFR;188.213.173.69;42000;001 -91767;GB Fusion Kernow;Fusion SW UK;91.121.101.163;43000;002 -97576;GB N.Ireland;YSF N.Ireland;91.121.101.163;42500;004 -76849;GR YSF202;Fusion Greece;144.76.101.219;42000;006 -25419;Guatemala;CentOS7;74.208.88.137;42000;003 -47247;HB C4FM Basel;CISAR Basel;212.237.33.114;42000;002 -62928;HBLINK EA5GVK;HBLINK EA5GVK;84.127.124.188;42000;000 -98367;HK WTT YSF;No bridge;218.255.238.138;42006;004 -41120;HU Hungary;BM TG2167;213.181.208.141;42100;001 -04251;IE YSF Ireland;Fusion <> DMR;87.44.19.111;42000;011 -94264;IT C4FM ENNA;HAMRADIOENNA #;94.176.6.45;42000;000 -67939;IT C4FM LAZIO;773RadioGroup;93.186.255.126;42000;002 -30483;IT C4FM Lodi;Lombardia;79.54.231.198;42000;002 -51231;IT C4FM NORD;ITALY-NORD;78.47.154.19;42000;006 -19437;IT C4FM Piemonte;DSP Italy;94.177.173.53;42000;004 -64159;IT ITALY-FREE;c4fm bridge;37.187.106.175;42000;003 -82044;IT YSFROOM-ITALY;WIRES-X ITALY;94.177.187.40;42000;012 -67411;IT Zona 4;EmiliaRomagna;212.84.32.29;42000;000 -25383;JP JAPAN;Fusion Japan;202.241.175.133;42000;002 -96455;NL Central;Centraal NL;90.145.156.196;42000;004 -85875;NL Fusion Almere;Flevoland;84.86.62.38;42000;018 -73238;NL Noord;test reflector;44.137.87.82;42000;001 -63539;NL Oost;test reflector;44.137.87.83;42000;002 -73443;NL PI1DAF;Multi Repeater;77.174.30.155;42000;003 -66644;NL YSF amprnet;ampr reflector;44.137.33.52;42000;000 -38627;NL YSF444;Dutch Refl.;188.68.37.51;42000;003 -56254;NO YSF006;Norway;80.89.46.242;42000;009 -88973;NZ NZ750;XLX750 NZ;210.55.201.126;42000;002 -49480;NZ NZXLX;XLX626;202.137.244.157;42000;002 -46031;NZ ZL2VH;ZL2VH YSF;123.255.47.67;42000;002 -37761;OklahomaLink;OklahomaLink;70.189.115.214;42000;004 -00001;Parrot;Parrot;213.202.229.15;42020;000 -25393;PL 4280;YSF/DMR/DCS132;94.246.175.66;42031;002 -98564;PL EmCom;EmCom TG260023;195.26.76.59;42023;001 -29114;PL POLAND;POLAND WiresX;94.246.175.66;42025;005 -38274;PL Poland 21;DMR TG260021;195.26.76.59;42021;001 -04463;PL Poland 22;DMR TG260022;195.26.76.59;42022;001 -55546;PL Silesia;Poland Silesia;188.116.7.66;42001;000 -11533;PL SR8DMR;RTCN Chotycze;94.246.175.66;42029;001 -78099;PL SR8FWD;Wlodawa WiresX;94.246.175.66;42030;001 -91407;PL SR8LUF;Lublin;94.246.175.66;42028;001 -61506;PL SR8UD;Ustrzyki;94.246.175.66;42032;000 -54644;PL SR8UWD;Wlodawa YSF;94.246.175.66;42027;001 -80986;PL YSF260;BM TG260;94.246.175.66;42035;001 -09948;PT YSF009;C4FM-Portugal;109.71.44.237;42000;005 -89355;R.E.E.C.;R.E.E.C.;5.135.137.65;42000;000 -13131;ref.c4fm.se;ref.c4fm.se;176.10.140.161;42000;004 -23116;RO MULTIMODE;BM TG2260;94.176.6.37;42005;002 -99447;RO YSF226;BM TG226;94.176.6.37;42000;004 -00229;RO YSF<->Wires-X;C4FM Reflector;94.176.6.37;42001;002 -40208;SC Scotland;Scottish YSF;13.69.14.204;42000;008 -43699;SE SK7ES;SK7ES Fusion;44.140.236.22;42000;000 -77010;SE SW-Sweden;C4FM;46.236.122.101;52000;000 -07237;TechTalk24;Engineers talk;195.26.76.59;42024;002 -43513;TROJMIASTO;Poland Tricity;195.140.190.58;42000;001 -30743;TW HAMTALK;C4FM @HAMTALK;118.150.164.96;42000;001 -00325;TW YSF886;C4FM Taiwan;118.163.103.178;42000;000 -13201;UK DVMEGA;DVMEGA CHAT;212.237.34.32;42000;013 -93019;UK DVMEGA SH;DVMEGA CHAT SH;212.237.18.27;42000;002 -83087;UK_YSF_BM_UK;UK_Ref_DN_ONLY;91.121.101.163;42000;018 -21988;US AggielandLink;Aggieland Link;71.252.210.227;42000;003 -22647;US BM TG 31254;Carolina Link;52.3.47.55;42000;005 -51512;US BM TG 3137;North Carolina;52.3.47.55;42001;001 -74185;US BM-TG3139;DMR-313960-To-;52.54.69.145;42000;003 -49235;US CKRG;Central Kansas;198.211.109.207;42000;002 -39906;US COLORADO-LINK;Colorado Link;13.78.187.50;42000;006 -84105;US East PA;MMDVM System;173.49.20.45;42005;000 -04162;US GLOBAL DX;Global DX;206.72.198.26;42000;002 -30725;US K7EVR YSF;EVAR Mesa,AZ;72.201.150.71;42000;001 -02912;US Nationwide;United States;174.36.222.36;42000;016 -53594;US Ohio;Ohio;162.243.74.151;42000;001 -62554;US Texas-Nexus;Texas-Nexus;104.2.186.135;42000;022 -80767;US TGIF-BM 31665;US TGIF-BM 316;162.248.92.62;42000;013 -98899;US WolfDen;Massachusetts;100.0.26.120;42000;002 -90943;US YSF 858;YSF SDCA-NZ6D;104.236.156.191;42000;001 -08033;US YSF002;KingsOfDigital;52.10.253.1;42000;001 -91768;US YSF082 NYC;KARG & NB2O;108.21.232.23;42000;002 -23864;US YSF310;K6KD;64.137.191.209;42000;001 -96429;US-KansasLink;Kansas C4FM Re;72.205.226.24;42000;006 -87531;US-QuadNetATL;QuadNet-BM;107.191.121.105;42000;001 -74247;US-RepeaterBook;DMR TG 31419;69.71.127.9;42000;002 -12224;US-YSF-NE;NEW-ENGLAND;54.144.216.63;42000;009 -33386;US-YSF570;NEPA Fusion Sy;104.128.230.153;42000;000 -88051;US-YSF587NYS;YSF-QNetBridge;216.155.157.11;42000;002 -41577;YSF YO W;Fusion Romania;89.122.215.236;42000;003 -91559;YSF-BRAZIL;C4FM-BRAZIL;200.231.36.174;42000;004 -24519;YSF-EA5 SPAIN;Zona EA5;84.127.124.188;42105;006 -93029;YSF004 MI5 SW2;Crossconnect t;44.103.34.3;42000;001 -65576;YSF937;Guri, South Ko;1.240.221.206;42000;000 +65702;0 OE-Austria;Official;94.199.173.123;42000;001;http://c4fm-austria.dyndns.org:46193 +38089;0077;IRLP/DMR Esp;216.21.9.156;42000;000;xe1dvi.crabdance.com/html/index.php +74652;119-YSF;TG45004 XLX170;125.129.207.86;42000;003;http://ysf119.dvham.com/index.php +89803;A.O.T. Roma;OndaTelematica;31.14.140.230;42000;000;http://www.ondatelematica.it +02034;Alabama-Link;Alabama-Link;199.119.98.174;42000;049;http://ysf.alabamalink.info/ +64230;America-RC;YSF-TO-WIRES-X;65.101.7.49;42000;009;http://65.101.7.49 +88060;AREC US FL-727;C4FM Bridge BM;97.76.81.165;42000;000;http://ysf.inerrantenergy.com/ysf/ +38654;ARGENTINA;C4FM Team;212.237.3.87;42000;010;http://ysfargentina.mmdvm.es +59330;ARRGUS Array;Florida USA;96.94.7.200;42000;002;http://ysf.arrg.us +42586;ARRGUS_ArrayN;Back up server;64.137.194.85;42000;001;http://ysf6.arrg.us +25223;AT Austria OE1;OE1PHS;213.47.71.17;42000;004;http://oe1phs.ddns.net/YSFReflector-Dashboard/ +00396;AT Austria OE3;OE3AAS;77.117.158.250;42100;001;http://oe3aas.ddns.net/YSFReflector-Dashboard/ +59911;AT Austria OE8;OE8VIK;62.203.54.167;42000;004;http://oe8vik.ddns.net/YSFReflector-Dashboard +55693;AT C4FM Austria;YSF;89.185.97.38;42000;021;http://c4fm.oevsv.at/ysf +04201;AU YSF001;1st WW YSF;125.63.61.26;42000;018;http://ysf001.duckdns.org +93760;BE YSF-Vlaandere;C4FM Vlaandere;81.95.126.168;42000;003;http://ysf.on4top.be/ysf +79520;BE YSF-Wallonie;C4FM Wallon;51.255.193.63;42000;004;http://www.ysfwallonie.net/ +67661;BG Bulgaria;Sysop: LZ1LCD;95.43.222.149;42000;001;http://fusion.spirka.net +37692;BM TG28412;Test;193.93.24.29;42000;001;http://ysf.ham-dmr.bg/ +47573;BM-EA-TG914;BM-EA-TG914;104.223.70.166;42000;003;http://104.223.70.166/ysf/ +14341;BM-TG-208;BrMstr TG208;51.254.126.212;42000;002; +30745;BM-TG-2080;BrMstr TG2080;51.254.126.212;42080;001; +00872;BM-TG-20820;BrMstr TG20820;51.254.126.212;42020;001; +37594;BM-TG-20845;BrMstr TG20845;51.254.126.212;42045;001; +52846;BM-TG-20859;BrMstr TG20859;51.254.126.212;42059;002; +39552;BM-TG-2087;BrMstr TG2087;51.254.126.212;42007;001; +93206;BM-TG-2088;BrMstr TG2088;51.254.126.212;42008;001; +81116;BM-TG-20883;BrMstr TG20883;51.254.126.212;42083;002; +35402;BM-TG-2089;BrMstr TG2089;51.254.126.212;42009;001; +36096;BR YSF724;C4FM - DV Braz;66.55.64.14;42000;007;http://ysf.dvbrazil.com.br/ +85044;C4FM-SEOUL;TG45004 XLX170;121.162.91.45;42000;008;http://ysfso.dvham.com/indexysf.php +77353;CA Canada;C4FM Ontario;144.217.241.23;42100;007;http://c4fmontario.hopto.org +49473;CA QUEBEC;QC FR Fusion;64.34.60.44;42000;002;http://www.ve2mrc.com/ysfr/index.php +79602;Carolina Link;Carolina Link;52.3.47.55;42000;003;http://52.3.47.55/index.php +30998;CH 228 Swiss;Bridge BM22820;176.10.105.210;42000;005;http://ysf.hb-connect.ch/ +52796;CH JOTA;Jota CH;157.161.57.65;42001;000; +80337;CN China #1;C4FM YSF;120.234.41.144;42000;038;http://ysf.sz790.com:8081/ +82442;CN China #2;W24269/TG46072;116.6.107.115;42006;005;http://ufozhuzi.tpddns.cn:8081/ +09724;CN China #99;YSF Test;103.107.105.251;42000;000;http://ysf.ncwxd.com +40973;CN-China-03;C4FM;123.58.6.137;42000;000;http://123.58.6.137:8088 +30490;CO 4 KILO MIKE;Antioquia;190.159.68.105;42000;000; +04523;CT CATALANA;C4FM Catalunya;85.214.119.76;42000;004;http://ysfcat.ea3hkb.com +30549;CT WIRESCAT;C4FM Catalunya;85.214.119.76;42001;012;http://wirescat.ea3hkb.com +26541;CZ Czech;TG2300 DCS019V;80.250.3.114;42000;009;http://80.250.3.114/index.php +77329;CZ YSF Praha;CZ YSF Praha;185.32.183.148;42000;005;http://185.32.183.148/ysf/ +63382;DAHSOB;DAH / SOB;91.61.232.8;42000;001; +80861;DE DL-NORD;AFu-Nord.de;5.45.96.68;42000;002;http://funk-sh.de +54919;DE DL-NORDWEST;Nordwest-DL;84.140.31.216;42000;017;http://dl-nordwest.spdns.de +62829;DE Germany;TG26208;213.202.229.15;42000;028;https://c4fm.ysfreflector.de/Germany +74154;DE PEGASUS;Multi-Bridge;78.46.11.65;42000;015;https://status.projekt-pegasus.net/ +20548;DE PEGASUS2;Test System;78.46.11.65;42001;000;https://status.projekt-pegasus.net/ +63421;DE Ruhrgebiet;Ruhrgebiet;144.76.12.90;42000;005;http://dg3yjb.beba.re/YSFReflector +15017;DE Saarland;darc-saar.de;213.202.229.220;42000;000;https://c4fm.darc-saar.de/ +95352;DE Twitterrunde;GW BM TG263333;213.202.229.15;42001;004;https://c4fm.ysfreflector.de/Twitterrunde +00561;DVSwitch NA;North America;44.103.32.18;42000;001;http://dvswitch.org/ysfreflector/ +94533;EA Distrito 1;Wires X Spain;212.237.30.36;42000;000;http://ysfdistrito1.mmdvm.es/ +42493;EA Distrito 2;EDT;185.47.129.230;42000;003;http://server.ea2ip.com/ysf/ +48495;EA Distrito 3;Wires X Spain;89.38.150.252;42000;001;http://ysfdistrito3.mmdvm.es/ +62980;EA Distrito 4;REM SPAIN;212.237.0.67;42000;000;http://ysfdistrito4.mmdvm.es/ +39908;EA Distrito 5;YSF EALINK;216.86.147.198;42000;000;http://ysfdistrito5.mmdvm.es/ +58314;EA Distrito 7;RC Veleta;212.237.11.53;42000;009;http://ysfdistrito7.mmdvm.es/ +37172;EA Sevilla;Prov Sevilla;204.44.93.190;42000;004;http://ysfsevilla.mmdvm.es/ +01439;EMCOM SPAIN;Emergency;212.237.17.133;42000;000;http://ysf.emcomspain.xreflector.es/ +32027;ES ADER;ASSOCIACIO;80.211.226.198;42000;002;http://80.211.226.198/index_dashboard.php +18423;ES andalucia-esp;andalucia EA7;94.177.196.120;42000;000;ysfandalucia.ddns.net +26260;ES CORDOBA-ESP;CORDOBA;80.211.131.156;42000;001;http://www.ea7or.es +98529;ES ED2ZAE;Multiporpouse;94.177.237.192;42000;001;http://ysf900.dyndns.org/ysf +15642;ES REM SPAIN;REM YSF REF;213.37.155.58;42000;000;http://rem-esp.es +60318;ES Wires X;WIRES X SPAIN;80.211.236.189;42000;018;http://ysf.xreflector.es/ +86886;FR Room-ZIT;Room F1ZIT;151.80.143.185;42002;009;http://151.80.143.185/zit/YSFReflector-Dashboard/ +39510;FR wiresxfrance;Wires-X-France;151.80.143.185;42000;000;http://151.80.143.185/WXF/YSFReflector-Dashboard/index.php +59495;FR YSF St Amand;St Amand (59);51.15.172.24;42000;002;https://srv.hambox.fr/dashboard/ +83665;FR YSF-Alpes;Rhone-Alpes;217.182.66.229;42000;001;http://ysf-alpes.f4gve.net +60284;FR YSF-Alsace;Room (67-68);91.121.136.94;42000;001;http://c4fm.vulcain.space/ +19531;FR YSF-Bretagne;Bretagne;78.206.208.208;42000;000;http://78.206.208.208:8081/YSFReflector-Dashboard/index.php +13844;FR YSF-Cappelle;YSF Room F1ZKY;92.188.0.108;42000;001;http://ysf.a3rn.org:2626 +58617;FR YSF-France;Fusion France;87.98.132.205;42000;031;http://ysf-france.fr/ +91713;FR YSF-Limouzi;C4FM Limousin;88.174.140.210;42000;001;http://ysf-limousin.dyndns.org:8787 +46353;FR YSF-Nord;Nord;178.32.163.106;42000;003; +33751;FUSION-ITALY;Italy YSFR;188.213.173.69;42000;002;http://c4fm-it.selfip.com/ +91767;GB Fusion Kernow;Fusion SW UK;87.117.229.165;43000;001;http://ysf.mb6cc.co.uk +86111;GB Midlands;YSF Mids GB;86.181.124.242;42021;003; +97576;GB N.Ireland;YSF N.Ireland;87.117.229.165;42500;004; +16710;GB SOUTH WEST;YSF REFLECTOR;31.51.76.253;43000;003;http://g8koe.ddns.net:8000/ +25419;Guatemala;CentOS7;74.208.88.137;42000;005;http://74.208.88.137/YSF/index.php +47247;HB C4FM Basel;CISAR Basel;212.237.33.114;42000;000;http://212.237.33.114/c4fm/index.php +62928;HBLINK EA5GVK;HBLINK EA5GVK;84.127.124.188;42000;000;http://ea5gvk.duckdns.org:84/YSFReflector +29256;HK-WTT-YSF;BM TG460790;218.255.238.138;42006;003;http://218.255.238.138/Dashboard/ +41120;HU Hungary;BM TG216;185.187.75.192;42100;001;http://brandmeister.hu/ysfref/ +04251;IE YSF Ireland;Fusion <> DMR;87.44.19.111;42000;009; +94264;IT C4FM ENNA;HAMRADIOENNA #;94.176.6.45;42001;000;http://ysf.hamradioenna.it +67939;IT C4FM LAZIO;773RadioGroup;93.186.255.126;42000;001;http://ysf.iz0rin.it/ysf/ +30483;IT C4FM Lodi;Lombardia;79.51.62.21;42000;001;http://ysf.iw2gob.it/c4fm/index.php +51231;IT C4FM NORD;ITALY-NORD;78.47.154.19;42000;006;http://italy-nord.dyndns.biz/dashboard/index.php +19437;IT C4FM Piemonte;DSP Italy;94.177.173.53;42000;003;http://94.177.173.53:8085/c4fm/index.php +14115;IT C4FM PUGLIA;C4FM Puglia It;94.177.164.25;42000;000;http://c4fm-puglia.iz7auh.net/YSFReflector-Dashboard/index.php +12624;IT C4FM SUD;ITALY-SUD;212.237.59.103;42000;000;http://c4fm-italy-sud.iz7auh.net/YSFReflector-Dashboard/index.php +47946;IT Digiland;Italia;212.227.203.37;42000;000;http://212.227.203.37/ysf/index.php +82915;IT Digiland 2;Italia;185.203.118.135;42000;000;http://185.203.118.135/ysf +30942;IT Digiland 3;Italia;85.217.170.178;42000;000;http://85.217.170.178/ +64120;IT DSTAR-LINK;LINK DSTAR;80.211.156.219;42000;002;http://80.211.156.219/index.php +58288;IT GDO FUSION;C4FM Ossola;78.134.125.81;42001;000;http://iz1zpj.ddns.net/c4fm/index.php +64159;IT ITALY-FREE;c4fm bridge;37.187.106.175;42000;002; +34697;IT SICILIA;C4FM REFLECTOR;94.176.6.45;42000;004;http://sicilia.c4fm.it +82044;IT YSFROOM-ITALY;WIRES-X ITALY;94.177.187.40;42000;029;http://ysfroomitaly.iw2gob.it/c4fm/index.php +67411;IT Zona 4;EmiliaRomagna;212.84.32.29;42000;001; +70220;ITALY-I5-PT;C4FM Pistoia;95.235.200.175;42000;001;http://iu5hju.ddns.net/index.php +70542;Japan ShounanYSF;Japan ShounanY;133.130.114.45;42000;001;http://shounandstar.dip.jp/ysf/ +25383;JP JAPAN;Fusion Japan;122.222.1.50;42000;010;http://c4fm.owari.biz/ysfref/ +13870;KAVKAZ;RUS, North Cau;37.18.35.2;42000;002; +20457;Miami-LATINO;C4FM;80.211.175.168;42000;000;http://80.211.175.168/ +23944;MX Fusion Mexico;Fusion Mexico;200.57.9.10;42000;002;http://200.57.9.10 +11714;MY Malaysia Net;Malaysia Net;150.129.184.54;42000;001;http://ysf.myaprs.my/ysf/index.php +96455;NL Central;Centraal NL;90.145.156.196;42000;024;http://c4fm.pa7lim.nl/ +85875;NL Fusion Almere;Flevoland;84.86.62.38;42000;002;http://c4fm-pe1gdf.nl +92034;NL ItaNed;Test reflector;83.162.231.214;42000;000; +73238;NL Noord;test reflector;44.137.87.82;42000;001;http://44.137.87.82/index.php +63539;NL Oost;test reflector;44.137.87.83;42000;002;http://44.137.87.83/index.php +73443;NL PI1DAF;Multi Repeater;77.174.30.155;42000;002;http://pd0poh.ddns.net +66644;NL YSF amprnet;ampr reflector;44.137.33.52;42000;000;http://44.137.33.52/index.php +38627;NL YSF444;Dutch Refl.;188.68.37.51;42000;001;http://ysf444.pa3dfn.nl +56254;NO YSF006;Norway;80.89.46.242;42000;015; +46031;NZ ZL2VH;ZL2VH YSF;123.255.47.67;42000;006;http://123.255.47.67:84 +48038;Ohio-Link;Ohio-Link;75.76.129.38;42000;006; +37761;OklahomaLink;Wires21733,BM3;70.189.115.214;42000;006;http://oklahomalink.duckdns.org:2080 +00001;Parrot;Parrot;213.202.229.15;42020;000; +25393;PL 4280;YSF/DMR/DCS132;94.246.175.66;42031;003;https://brandmeister.network/?page=lh&DestinationID=260080 +29114;PL POLAND;POLAND WiresX;94.246.175.66;42025;015;https://brandmeister.network/?page=lh&DestinationID=260042 +55546;PL Silesia;Poland Silesia;188.116.7.66;42001;001;http://ysfsilesia.pzk.pl/ +38691;PL SR4H;SR4H-ROOM;91.244.185.128;42000;002; +11533;PL SR8DMR;RTCN Chotycze;94.246.175.66;42029;001;http://ysf016.wiresx.pl:8081/sr8dmr/ +78099;PL SR8FWD;Wlodawa WiresX;94.246.175.66;42030;001;http://sr8fwd.wiresx.pl +79009;PL SR8K;Dubiecko;94.246.175.66;42032;001;http://ysf016.wiresx.pl:8081/sr8k/ +91407;PL SR8LUF;Lublin;94.246.175.66;42028;001;http://ysf016.wiresx.pl:8081/sr8luf/ +87318;PL SR8UVC;Chotylow;94.246.175.66;42034;001; +54644;PL SR8UWD;Wlodawa YSF;94.246.175.66;42027;001;http://sr8uwd.wiresx.pl +74470;PL SR9FSR;Wola YSF;188.116.7.66;42002;001;http://ysfsr9fsr.pzk.pl/ +80986;PL YSF260;BM TG260;94.246.175.66;42035;003;http://ysf016.wiresx.pl:8081/260/ +09948;PT YSF009;C4FM-Portugal;109.71.44.237;42000;004;http://c4fm.from-ct.com/ysf/ +89355;R.E.E.C.;R.E.E.C.;5.135.137.65;42000;001;http://www.reec.be/ysf +13131;ref.c4fm.se;ref.c4fm.se;176.10.140.161;42000;005;http://ref.c4fm.se +07931;RO YO QSO Party;C4FM Reflector;94.176.6.37;42001;001;http://wiresx.226.ro/ +50662;RO-CafeGratis;BM TG2260;94.176.6.37;42005;001;http://ysf.cafegratis.club +06955;Salento Digital;-;185.203.118.8;42000;001;http://185.203.118.8/ +40208;SC Scotland;Scottish YSF;13.69.14.204;42000;012;http://c4fm.dvscotland.net +43699;SE SK7ES;SK7ES Fusion;44.140.236.22;42000;002;http://ysf.sm7.hamnet.nu +77010;SE SW-Sweden;C4FM;46.236.122.101;52000;000;http://sm4wdq.hopto.org:9999/ +48857;SI-Slovenia;TG293;84.52.159.10;42000;004;http://xlx511.ddns.net:46193/index.php +94513;TH YSF520;C4FM THAILAND;119.59.125.192;42000;004;http://ysf.dtdxa.com +43513;TROJMIASTO;Poland Tricity;195.140.190.58;42000;001;http://ysftricity.ham-dmr.pl +30743;TW HAMTALK;C4FM @HAMTALK;118.150.164.96;42000;003;http://www.hamtalk.net/ysfr +00325;TW YSF886;C4FM Taiwan;118.163.103.178;42000;004;http://xlx886.metropit.net/ysfr/ +13201;UK DVMEGA;DVMEGA CHAT;212.237.34.32;42000;007;http://c4fm.dvmega.co.uk +93019;UK DVMEGA SH;DVMEGA CHAT SH;212.237.18.27;42000;002;http://212.237.18.27/ysf/ +83087;UK_YSF_BM_UK;UK_Ref_DN_ONLY;87.117.229.171;42000;030; +21988;US AggielandLink;Aggieland Link;71.252.210.227;42000;001;http://www.aggielandlink.com/Dashboard +51512;US BM TG 3137;North Carolina;52.3.47.55;42001;002;http://52.3.47.55/NC/index.php +93196;US BM TG 31444;RI Digital Hub;54.68.216.180;42001;003;http://southeast.digitallink.us/RI/ +49235;US CKRG;Central Kansas;198.211.109.207;42000;004; +39906;US COLORADO-LINK;Colorado Link;13.78.187.50;42000;012;http://cartradioysf.ae2l.net +84105;US East PA;MMDVM System;173.49.20.45;42005;001;http://www.wb0yle.com:8484 +04162;US GLOBAL DX;Global DX;206.72.198.26;42000;005;http://206.72.198.26/ysf +83132;US Illinois Link;Illinois Link;74.208.235.115;42000;007;http://74.208.235.115/index.php +80374;US K4BUM;K4BUM-Group;35.196.9.211;42000;002; +99597;US Kingsland;Kingsland GA;54.68.216.180;42000;003;http://w1kfr.from-ga.com/GA/index.php +02912;US Nationwide;United States;174.36.222.36;42000;035;http://ysf.kc2idb.net/index.php +48139;US nature coast;nature coast;47.206.21.6;42000;004;http://47.206.21.6:81 +85788;US NJ EXP;US NJ EXP;64.137.243.122;42000;000;http://xrf.njpaasterisk.org +83242;US NW-Ohio;YSF-WiresX-284;52.54.69.145;42000;001;http://ysf.k8xg.com +53594;US Ohio;Ohio;162.243.74.151;42000;001;http://ysf.n8qq.com +09585;US RFIT;YSF TO DMR;73.233.224.103;42000;003; +84398;US SADRC;SanAntonioDRC;71.78.10.76;42000;012; +62554;US Texas-Nexus;Texas-Nexus;104.2.186.135;42000;020;http://ysf.texas-nexus.dyndns.org/ysf/ +80767;US TGIF-BM 31665;US TGIF-BM 316;162.248.92.62;42000;011;http://n2nuo.com/ysf/index.php +76864;US Triangle NC;Triangle NC;192.223.28.198;42000;002;http://ysf.trianglenc.net +98899;US WolfDen;Massachusetts;100.0.26.120;42000;001;http://wolfden.ddnsgeek.com:42080 +38268;US YSF 012;PAPA YSF 012;209.112.244.28;42000;004;http://ysfr012.papasys.com +90943;US YSF 858;YSF SDCA-NZ6D;104.236.156.191;42000;000;http://nz6d.dx40.com/ysf +08033;US YSF002;KingsOfDigital;52.10.253.1;42000;002;http://ysf002.dstar.club +91768;US YSF082 NYC;KARG & NB2O;108.21.232.23;42000;001;http://ysf082.pungsan.com/ +23864;US YSF310;K6KD;64.137.191.209;42000;000;http://ysf310.xrefl.net +96429;US-KansasLink;Kansas C4FM Re;23.119.252.30;42000;006;http://kansas-ysf.dyndns.org:8675/index.php +87531;US-QuadNetATL;QuadNet-BM;107.191.121.105;42000;004;http://ysfr1.openquad.net/ +74247;US-RepeaterBook;DMR TG 31419;69.71.127.9;42000;002;http://matfield.heartlandtower.com:8675 +12224;US-YSF-NE;NEW-ENGLAND;54.144.216.63;42000;005;http://ysf.wizworks.net:41000/ +88051;US-YSF587NYS;YSF-QNetBridge;216.155.157.11;42000;001;http://ysfopenquad.ddns.net +54595;Virginia;Virginia YSF;45.33.118.112;42000;003;http://45.33.118.112/ysf/ +38635;Wires-X YO W;WiresX Romania;89.122.215.236;42001;004;http://wiresx.hamnet.ro +70375;YSF BRAZIL;C4FM BRAZIL PU;200.231.36.174;42000;007;http://ysf.pu2lrz.com +41577;YSF YO W;Fusion Romania;89.122.215.236;42000;009;http://ysf.hamnet.ro +24519;YSF-EA5 SPAIN;Zona EA5;84.127.124.188;42105;006;http://ea5gvk.duckdns.org:84/YSF +26626;YSF-TI;YSF Tango Indi;159.89.183.117;42000;000; +93029;YSF004 MI5 SW2;Crossconnect t;44.103.34.3;42000;003;http://ysf004.kb8zgl.net/YSFReflector +65576;YSF937;Guri, South Ko;1.240.221.206;42000;000;http://sojubox.iptime.org:8080/ysfreflector/ +31741;YSFColombiaLR;LCRA Fusion;120.146.216.45;42000;001;http://120.146.216.45/index.php diff --git a/YSFGateway/Network.cpp b/YSFGateway/YSFNetwork.cpp similarity index 64% rename from YSFGateway/Network.cpp rename to YSFGateway/YSFNetwork.cpp index f643a43..b291be6 100644 --- a/YSFGateway/Network.cpp +++ b/YSFGateway/YSFNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2017,2018 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 @@ -17,7 +17,7 @@ */ #include "YSFDefines.h" -#include "Network.h" +#include "YSFNetwork.h" #include "Utils.h" #include "Log.h" @@ -27,14 +27,17 @@ const unsigned int BUFFER_LENGTH = 200U; -CNetwork::CNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : +CYSFNetwork::CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) : m_socket(address, port), m_debug(debug), m_address(), m_port(0U), m_poll(NULL), m_unlink(NULL), -m_buffer(1000U, "YSF Network Buffer") +m_buffer(1000U, "YSF Network Buffer"), +m_pollTimer(1000U, 5U), +m_name(), +m_linked(false) { m_poll = new unsigned char[14U]; ::memcpy(m_poll + 0U, "YSFP", 4U); @@ -51,14 +54,15 @@ m_buffer(1000U, "YSF Network Buffer") } } -CNetwork::CNetwork(unsigned int port, const std::string& callsign, bool debug) : +CYSFNetwork::CYSFNetwork(unsigned int port, const std::string& callsign, bool debug) : m_socket(port), m_debug(debug), m_address(), m_port(0U), m_poll(NULL), m_unlink(NULL), -m_buffer(1000U, "YSF Network Buffer") +m_buffer(1000U, "YSF Network Buffer"), +m_pollTimer(1000U, 5U) { m_poll = new unsigned char[14U]; ::memcpy(m_poll + 0U, "YSFP", 4U); @@ -75,64 +79,74 @@ m_buffer(1000U, "YSF Network Buffer") } } -CNetwork::~CNetwork() +CYSFNetwork::~CYSFNetwork() { delete[] m_poll; } -bool CNetwork::open() +bool CYSFNetwork::open() { LogMessage("Opening YSF network connection"); return m_socket.open(); } -void CNetwork::setDestination(const in_addr& address, unsigned int port) +void CYSFNetwork::setDestination(const std::string& name, const in_addr& address, unsigned int port) { + m_name = name; m_address = address; m_port = port; + m_linked = false; } -void CNetwork::clearDestination() +void CYSFNetwork::clearDestination() { m_address.s_addr = INADDR_NONE; m_port = 0U; + m_linked = false; + + m_pollTimer.stop(); } -bool CNetwork::write(const unsigned char* data) +void CYSFNetwork::write(const unsigned char* data) { assert(data != NULL); if (m_port == 0U) - return true; + return; if (m_debug) CUtils::dump(1U, "YSF Network Data Sent", data, 155U); - return m_socket.write(data, 155U, m_address, m_port); + m_socket.write(data, 155U, m_address, m_port); } -bool CNetwork::writePoll() +void CYSFNetwork::writePoll(unsigned int count) { if (m_port == 0U) - return true; + return; + + m_pollTimer.start(); - return m_socket.write(m_poll, 14U, m_address, m_port); + for (unsigned int i = 0U; i < count; i++) + m_socket.write(m_poll, 14U, m_address, m_port); } -bool CNetwork::writeUnlink() +void CYSFNetwork::writeUnlink(unsigned int count) { + m_pollTimer.stop(); + if (m_port == 0U) - return true; + return; - return m_socket.write(m_unlink, 14U, m_address, m_port); + for (unsigned int i = 0U; i < count; i++) + m_socket.write(m_unlink, 14U, m_address, m_port); + + m_linked = false; } -void CNetwork::clock(unsigned int ms) +void CYSFNetwork::clock(unsigned int ms) { - if (m_port == 0U) - return; - unsigned char buffer[BUFFER_LENGTH]; in_addr address; @@ -141,9 +155,21 @@ void CNetwork::clock(unsigned int ms) if (length <= 0) return; + if (m_port == 0U) + return; + + m_pollTimer.clock(ms); + if (m_pollTimer.isRunning() && m_pollTimer.hasExpired()) + writePoll(); + if (address.s_addr != m_address.s_addr || port != m_port) return; + if (::memcmp(buffer, "YSFP", 4U) == 0 && !m_linked) { + LogMessage("Linked to %s", m_name.c_str()); + m_linked = true; + } + if (m_debug) CUtils::dump(1U, "YSF Network Data Received", buffer, length); @@ -153,7 +179,7 @@ void CNetwork::clock(unsigned int ms) m_buffer.addData(buffer, length); } -unsigned int CNetwork::read(unsigned char* data) +unsigned int CYSFNetwork::read(unsigned char* data) { assert(data != NULL); @@ -168,7 +194,7 @@ unsigned int CNetwork::read(unsigned char* data) return len; } -void CNetwork::close() +void CYSFNetwork::close() { m_socket.close(); diff --git a/YSFGateway/Network.h b/YSFGateway/YSFNetwork.h similarity index 65% rename from YSFGateway/Network.h rename to YSFGateway/YSFNetwork.h index fc023c5..30bfb39 100644 --- a/YSFGateway/Network.h +++ b/YSFGateway/YSFNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2014,2016,2017,2018 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 @@ -16,31 +16,32 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef Network_H -#define Network_H +#ifndef YSFNetwork_H +#define YSFNetwork_H #include "YSFDefines.h" #include "UDPSocket.h" #include "RingBuffer.h" +#include "Timer.h" #include #include -class CNetwork { +class CYSFNetwork { public: - CNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); - CNetwork(unsigned int port, const std::string& callsign, bool debug); - ~CNetwork(); + CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug); + CYSFNetwork(unsigned int port, const std::string& callsign, bool debug); + ~CYSFNetwork(); bool open(); - void setDestination(const in_addr& address, unsigned int port); + void setDestination(const std::string& name, const in_addr& address, unsigned int port); void clearDestination(); - bool write(const unsigned char* data); + void write(const unsigned char* data); - bool writePoll(); - bool writeUnlink(); + void writePoll(unsigned int count = 1U); + void writeUnlink(unsigned int count = 1U); unsigned int read(unsigned char* data); @@ -56,6 +57,9 @@ private: unsigned char* m_poll; unsigned char* m_unlink; CRingBuffer m_buffer; + CTimer m_pollTimer; + std::string m_name; + bool m_linked; }; #endif diff --git a/YSFGateway/Reflectors.cpp b/YSFGateway/YSFReflectors.cpp similarity index 80% rename from YSFGateway/Reflectors.cpp rename to YSFGateway/YSFReflectors.cpp index fe07c34..134f674 100644 --- a/YSFGateway/Reflectors.cpp +++ b/YSFGateway/YSFReflectors.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 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 @@ -16,7 +16,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "Reflectors.h" +#include "YSFReflectors.h" #include "Log.h" #include @@ -26,7 +26,7 @@ #include #include -CReflectors::CReflectors(const std::string& hostsFile, unsigned int reloadTime) : +CYSFReflectors::CYSFReflectors(const std::string& hostsFile, unsigned int reloadTime) : m_hostsFile(hostsFile), m_parrotAddress(), m_parrotPort(0U), @@ -39,7 +39,7 @@ m_timer(1000U, reloadTime * 60U) m_timer.start(); } -CReflectors::~CReflectors() +CYSFReflectors::~CYSFReflectors() { for (std::vector::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it) delete *it; @@ -68,19 +68,19 @@ static bool refComparison(const CYSFReflector* r1, const CYSFReflector* r2) return false; } -void CReflectors::setParrot(const std::string& address, unsigned int port) +void CYSFReflectors::setParrot(const std::string& address, unsigned int port) { m_parrotAddress = address; m_parrotPort = port; } -void CReflectors::setYSF2DMR(const std::string& address, unsigned int port) +void CYSFReflectors::setYSF2DMR(const std::string& address, unsigned int port) { m_YSF2DMRAddress = address; m_YSF2DMRPort = port; } -bool CReflectors::load() +bool CYSFReflectors::load() { for (std::vector::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it) delete *it; @@ -163,24 +163,39 @@ bool CReflectors::load() return true; } -CYSFReflector* CReflectors::find(const std::string& id) +CYSFReflector* CYSFReflectors::findById(const std::string& id) { - for (std::vector::iterator it = m_currReflectors.begin(); it != m_currReflectors.end(); ++it) { + for (std::vector::const_iterator it = m_currReflectors.cbegin(); it != m_currReflectors.cend(); ++it) { if (id == (*it)->m_id) return *it; } - LogMessage("Trying to find non existent reflector with an id of %s", id.c_str()); + LogMessage("Trying to find non existent YSF reflector with an id of %s", id.c_str()); + + return NULL; +} + +CYSFReflector* CYSFReflectors::findByName(const std::string& name) +{ + std::string fullName = name; + fullName.resize(16U, ' '); + + for (std::vector::const_iterator it = m_currReflectors.cbegin(); it != m_currReflectors.cend(); ++it) { + if (fullName == (*it)->m_name) + return *it; + } + + LogMessage("Trying to find non existent YSF reflector with a name of %s", name.c_str()); return NULL; } -std::vector& CReflectors::current() +std::vector& CYSFReflectors::current() { return m_currReflectors; } -std::vector& CReflectors::search(const std::string& name) +std::vector& CYSFReflectors::search(const std::string& name) { m_search.clear(); @@ -204,7 +219,7 @@ std::vector& CReflectors::search(const std::string& name) return m_search; } -bool CReflectors::reload() +bool CYSFReflectors::reload() { if (m_newReflectors.empty()) return false; @@ -221,7 +236,7 @@ bool CReflectors::reload() return true; } -void CReflectors::clock(unsigned int ms) +void CYSFReflectors::clock(unsigned int ms) { m_timer.clock(ms); diff --git a/YSFGateway/Reflectors.h b/YSFGateway/YSFReflectors.h similarity index 84% rename from YSFGateway/Reflectors.h rename to YSFGateway/YSFReflectors.h index 9ba8cb4..cb5fed4 100644 --- a/YSFGateway/Reflectors.h +++ b/YSFGateway/YSFReflectors.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX +* Copyright (C) 2016,2017,2018 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 @@ -16,8 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(Reflectors_H) -#define Reflectors_H +#if !defined(YSFReflectors_H) +#define YSFReflectors_H #include "UDPSocket.h" #include "Timer.h" @@ -45,17 +45,18 @@ public: unsigned int m_port; }; -class CReflectors { +class CYSFReflectors { public: - CReflectors(const std::string& hostsFile, unsigned int reloadTime); - ~CReflectors(); + CYSFReflectors(const std::string& hostsFile, unsigned int reloadTime); + ~CYSFReflectors(); void setParrot(const std::string& address, unsigned int port); void setYSF2DMR(const std::string& address, unsigned int port); bool load(); - CYSFReflector* find(const std::string& id); + CYSFReflector* findById(const std::string& id); + CYSFReflector* findByName(const std::string& name); std::vector& current();