diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index 37abd79..2efaf7e 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -70,6 +70,7 @@ m_aprsPort(0U), m_aprsSuffix(), m_aprsDescription(), m_networkStartup(), +m_networkOptions(), m_networkInactivityTimeout(0U), m_networkRevert(false), m_networkDebug(false), @@ -234,6 +235,8 @@ bool CConf::read() } else if (section == SECTION_NETWORK) { if (::strcmp(key, "Startup") == 0) m_networkStartup = value; + else if (::strcmp(key, "Options") == 0) + m_networkOptions = value; else if (::strcmp(key, "InactivityTimeout") == 0) m_networkInactivityTimeout = (unsigned int)::atoi(value); else if (::strcmp(key, "Revert") == 0) @@ -399,12 +402,12 @@ unsigned int CConf::getLogFileLevel() const std::string CConf::getLogFilePath() const { - return m_logFilePath; + return m_logFilePath; } std::string CConf::getLogFileRoot() const { - return m_logFileRoot; + return m_logFileRoot; } bool CConf::getAPRSEnabled() const @@ -437,6 +440,11 @@ std::string CConf::getNetworkStartup() const return m_networkStartup; } +std::string CConf::getNetworkOptions() const +{ + return m_networkOptions; +} + unsigned int CConf::getNetworkInactivityTimeout() const { return m_networkInactivityTimeout; @@ -459,7 +467,7 @@ bool CConf::getYSFNetworkEnabled() const unsigned int CConf::getYSFNetworkPort() const { - return m_ysfNetworkPort; + return m_ysfNetworkPort; } std::string CConf::getYSFNetworkHosts() const diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 7f07a9c..e050599 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -67,6 +67,7 @@ public: // The Network section std::string getNetworkStartup() const; + std::string getNetworkOptions() const; unsigned int getNetworkInactivityTimeout() const; bool getNetworkRevert() const; bool getNetworkDebug() const; @@ -134,6 +135,7 @@ private: std::string m_aprsDescription; std::string m_networkStartup; + std::string m_networkOptions; unsigned int m_networkInactivityTimeout; bool m_networkRevert; bool m_networkDebug; diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index c85f0b8..c89c6fb 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -89,6 +89,7 @@ m_fcsNetwork(NULL), m_linkType(LINK_NONE), m_current(), m_startup(), +m_options(), m_exclude(false), m_inactivityTimer(1000U), m_lostTimer(1000U, 120U), @@ -259,6 +260,7 @@ int CYSFGateway::run() } m_startup = m_conf.getNetworkStartup(); + m_options = m_conf.getNetworkOptions(); bool revert = m_conf.getNetworkRevert(); bool wiresXCommandPassthrough = m_conf.getWiresXCommandPassthrough(); @@ -808,6 +810,8 @@ void CYSFGateway::startupLinking() m_linkType = LINK_NONE; bool ok = m_fcsNetwork->writeLink(m_startup); + m_fcsNetwork->setOptions(m_options); + if (ok) { LogMessage("Automatic (re-)connection to %s", m_startup.c_str()); @@ -828,6 +832,8 @@ void CYSFGateway::startupLinking() if (reflector != NULL) { LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str()); + m_ysfNetwork->setOptions(m_options); + m_wiresX->setReflector(reflector); m_ysfNetwork->setDestination(reflector->m_name, reflector->m_addr, reflector->m_addrLen); diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index b74db45..c0d75ce 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -59,6 +59,7 @@ private: LINK_TYPE m_linkType; std::string m_current; std::string m_startup; + std::string m_options; bool m_exclude; CTimer m_inactivityTimer; CTimer m_lostTimer; diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index 104909b..c3376c8 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -39,6 +39,8 @@ Suffix=Y [Network] # Startup=FCS00120 # Startup=Alabama-Link +# book DG-ID for Reflector +# Options=20;21; InactivityTimeout=10 Revert=0 Debug=0 diff --git a/YSFGateway/YSFNetwork.cpp b/YSFGateway/YSFNetwork.cpp index a717cc2..52453ae 100644 --- a/YSFGateway/YSFNetwork.cpp +++ b/YSFGateway/YSFNetwork.cpp @@ -33,6 +33,7 @@ m_debug(debug), m_addr(), m_addrLen(0U), m_poll(NULL), +m_options(NULL), m_unlink(NULL), m_buffer(1000U, "YSF Network Buffer"), m_pollTimer(1000U, 5U), @@ -45,12 +46,16 @@ m_linked(false) m_unlink = new unsigned char[14U]; ::memcpy(m_unlink + 0U, "YSFU", 4U); + m_options = new unsigned char[50U]; + ::memcpy(m_options + 0U, "YSFO", 4U); + std::string node = callsign; node.resize(YSF_CALLSIGN_LENGTH, ' '); for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) { m_poll[i + 4U] = node.at(i); m_unlink[i + 4U] = node.at(i); + m_options[i + 4U] = node.at(i); } } @@ -60,6 +65,7 @@ m_debug(debug), m_addr(), m_addrLen(0U), m_poll(NULL), +m_options(NULL), m_unlink(NULL), m_buffer(1000U, "YSF Network Buffer"), m_pollTimer(1000U, 5U), @@ -72,12 +78,16 @@ m_linked(false) m_unlink = new unsigned char[14U]; ::memcpy(m_unlink + 0U, "YSFU", 4U); + m_options = new unsigned char[50U]; + ::memcpy(m_options + 0U, "YSFO", 4U); + std::string node = callsign; node.resize(YSF_CALLSIGN_LENGTH, ' '); for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) { m_poll[i + 4U] = node.at(i); m_unlink[i + 4U] = node.at(i); + m_options[i + 4U] = node.at(i); } } @@ -131,6 +141,22 @@ void CYSFNetwork::writePoll(unsigned int count) for (unsigned int i = 0U; i < count; i++) m_socket.write(m_poll, 14U, m_addr, m_addrLen); + + if (m_options != NULL) + m_socket.write(m_options, 50U, m_addr, m_addrLen); +} + +void CYSFNetwork::setOptions(const std::string& options) +{ + std::string opt = options; + + if (opt.size() < 1) + return; + + opt.resize(50, ' '); + + for (unsigned int i = 0U; i < (50 - 4 - YSF_CALLSIGN_LENGTH); i++) + m_options[i + 4U + YSF_CALLSIGN_LENGTH] = opt.at(i); } void CYSFNetwork::writeUnlink(unsigned int count) @@ -172,6 +198,9 @@ void CYSFNetwork::clock(unsigned int ms) LogMessage("Linked to %s", m_name.c_str()); m_linked = true; + + if (m_options != NULL) + m_socket.write(m_options, 50U, m_addr, m_addrLen); } if (m_debug) diff --git a/YSFGateway/YSFNetwork.h b/YSFGateway/YSFNetwork.h index 1125c72..3411aa8 100644 --- a/YSFGateway/YSFNetwork.h +++ b/YSFGateway/YSFNetwork.h @@ -41,6 +41,7 @@ public: void write(const unsigned char* data); void writePoll(unsigned int count = 1U); + void setOptions(const std::string& options = NULL); void writeUnlink(unsigned int count = 1U); unsigned int read(unsigned char* data); @@ -55,6 +56,7 @@ private: sockaddr_storage m_addr; unsigned int m_addrLen; unsigned char* m_poll; + unsigned char* m_options; unsigned char* m_unlink; CRingBuffer m_buffer; CTimer m_pollTimer; diff --git a/YSFReflector/Conf.cpp b/YSFReflector/Conf.cpp index 312a172..277fed1 100644 --- a/YSFReflector/Conf.cpp +++ b/YSFReflector/Conf.cpp @@ -172,12 +172,12 @@ unsigned int CConf::getLogFileLevel() const std::string CConf::getLogFilePath() const { - return m_logFilePath; + return m_logFilePath; } std::string CConf::getLogFileRoot() const { - return m_logFileRoot; + return m_logFileRoot; } unsigned int CConf::getNetworkPort() const