1
0
Fork 0

Reject unexpected incoming data.

ycs232-kbc
Jonathan Naylor 8 years ago
parent ea61019cba
commit 4966313167

@ -71,6 +71,7 @@ void CYSFReflector::run()
CTimer watchdogTimer(1000U, 0U, 1500U);
unsigned char tag[YSF_CALLSIGN_LENGTH];
unsigned char src[YSF_CALLSIGN_LENGTH];
unsigned char dst[YSF_CALLSIGN_LENGTH];
@ -80,6 +81,8 @@ void CYSFReflector::run()
unsigned int len = network.readData(buffer);
if (len > 0U) {
if (!watchdogTimer.isRunning()) {
::memcpy(tag, buffer + 4U, YSF_CALLSIGN_LENGTH);
if (::memcmp(buffer + 14U, " ", YSF_CALLSIGN_LENGTH) != 0)
::memcpy(src, buffer + 14U, YSF_CALLSIGN_LENGTH);
else
@ -91,8 +94,8 @@ void CYSFReflector::run()
::memcpy(dst, "??????????", YSF_CALLSIGN_LENGTH);
::fprintf(stdout, "Received data from %10.10s to %10.10s at %10.10s\n", src, dst, buffer + 4U);
}
else {
} else {
if (::memcmp(tag, buffer + 4U, YSF_CALLSIGN_LENGTH) == 0) {
bool changed = false;
if (::memcmp(buffer + 14U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(src, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
@ -108,7 +111,10 @@ void CYSFReflector::run()
if (changed)
::fprintf(stdout, "Received data from %10.10s to %10.10s at %10.10s\n", src, dst, buffer + 4U);
}
}
// Only accept transmission from an already accepted repeater
if (::memcmp(tag, buffer + 4U, YSF_CALLSIGN_LENGTH) == 0) {
watchdogTimer.start();
std::string callsign = std::string((char*)(buffer + 4U), YSF_CALLSIGN_LENGTH);
@ -125,6 +131,7 @@ void CYSFReflector::run()
watchdogTimer.stop();
}
}
}
// Refresh/add repeaters based on their polls
std::string callsign;

Loading…
Cancel
Save