|
|
@ -42,6 +42,7 @@ const char* DEFAULT_INI_FILE = "YSFReflector.ini";
|
|
|
|
const char* DEFAULT_INI_FILE = "/etc/YSFReflector.ini";
|
|
|
|
const char* DEFAULT_INI_FILE = "/etc/YSFReflector.ini";
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdarg>
|
|
|
|
#include <cstdarg>
|
|
|
@ -186,7 +187,7 @@ void CYSFReflector::run()
|
|
|
|
for (;;) {
|
|
|
|
for (;;) {
|
|
|
|
unsigned char buffer[200U];
|
|
|
|
unsigned char buffer[200U];
|
|
|
|
|
|
|
|
|
|
|
|
// Refresh/add repeaters based on their polls/simulated polls
|
|
|
|
// Refresh/add repeaters based on their polls
|
|
|
|
in_addr address;
|
|
|
|
in_addr address;
|
|
|
|
unsigned int port;
|
|
|
|
unsigned int port;
|
|
|
|
std::string callsign;
|
|
|
|
std::string callsign;
|
|
|
@ -212,6 +213,17 @@ void CYSFReflector::run()
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int len = network.readData(buffer);
|
|
|
|
unsigned int len = network.readData(buffer);
|
|
|
|
if (len > 0U) {
|
|
|
|
if (len > 0U) {
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 0U, "YSFU", 4U) == 0) {
|
|
|
|
|
|
|
|
std::string callsign = std::string((char*)(buffer + 4U), 10U);
|
|
|
|
|
|
|
|
CYSFRepeater* rpt = findRepeater(callsign);
|
|
|
|
|
|
|
|
if (rpt != NULL) {
|
|
|
|
|
|
|
|
LogMessage("Removing %s (unlinked)", callsign.c_str());
|
|
|
|
|
|
|
|
std::vector<CYSFRepeater*>::iterator it = std::find(m_repeaters.begin(), m_repeaters.end(), rpt);
|
|
|
|
|
|
|
|
if (it != m_repeaters.end())
|
|
|
|
|
|
|
|
m_repeaters.erase(it);
|
|
|
|
|
|
|
|
network.setCount(m_repeaters.size());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) {
|
|
|
|
if (!watchdogTimer.isRunning()) {
|
|
|
|
if (!watchdogTimer.isRunning()) {
|
|
|
|
::memcpy(tag, buffer + 4U, YSF_CALLSIGN_LENGTH);
|
|
|
|
::memcpy(tag, buffer + 4U, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
|
|
|
@ -260,6 +272,7 @@ void CYSFReflector::run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int ms = stopWatch.elapsed();
|
|
|
|
unsigned int ms = stopWatch.elapsed();
|
|
|
|
stopWatch.start();
|
|
|
|
stopWatch.start();
|
|
|
@ -279,7 +292,7 @@ void CYSFReflector::run()
|
|
|
|
|
|
|
|
|
|
|
|
for (std::vector<CYSFRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
|
|
|
for (std::vector<CYSFRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
|
|
|
if ((*it)->m_timer.hasExpired()) {
|
|
|
|
if ((*it)->m_timer.hasExpired()) {
|
|
|
|
LogMessage("Removing %s", (*it)->m_callsign.c_str());
|
|
|
|
LogMessage("Removing %s (polls lost)", (*it)->m_callsign.c_str());
|
|
|
|
m_repeaters.erase(it);
|
|
|
|
m_repeaters.erase(it);
|
|
|
|
network.setCount(m_repeaters.size());
|
|
|
|
network.setCount(m_repeaters.size());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -322,6 +335,16 @@ CYSFRepeater* CYSFReflector::findRepeater(const std::string& callsign, const in_
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CYSFRepeater* CYSFReflector::findRepeater(const std::string& callsign) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (std::vector<CYSFRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
|
|
|
|
|
|
|
if ((*it)->m_callsign == callsign)
|
|
|
|
|
|
|
|
return *it;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CYSFReflector::dumpRepeaters() const
|
|
|
|
void CYSFReflector::dumpRepeaters() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_repeaters.size() == 0U) {
|
|
|
|
if (m_repeaters.size() == 0U) {
|
|
|
|