Validate the NXDN protocol in the Parrot and Gateway.

This commit is contained in:
Jonathan Naylor 2018-03-15 19:21:59 +00:00
parent 6db1672ff7
commit 14ef0fb080
3 changed files with 13 additions and 9 deletions

View File

@ -91,16 +91,16 @@ void CIcomNetwork::clock(unsigned int ms)
if (length <= 0)
return;
// Invalid packet type?
if (::memcmp(buffer, "ICOM", 4U) != 0)
return;
// Check if the data is for us
if (m_address.s_addr != address.s_addr || port != m_port) {
LogMessage("Icom packet received from an invalid source, %08X != %08X and/or %u != %u", m_address.s_addr, address.s_addr, m_port, port);
return;
}
// Invalid packet type?
if (::memcmp(buffer, "ICOM", 4U) != 0)
return;
// An Icom repeater connect request
if (buffer[4U] == 0x01U && buffer[5U] == 0x61U) {
buffer[5U] = 0x62U;

View File

@ -130,10 +130,14 @@ unsigned int CNXDNNetwork::readData(unsigned char* data, unsigned int length, in
if (len <= 0)
return 0U;
if (m_debug)
CUtils::dump(1U, "NXDN Network Data Received", data, len);
if ((::memcmp(data, "NXDNP", 5U) == 0 && len == 15) || (::memcmp(data, "NXDND", 5U) == 0 && len == 43)) {
if (m_debug)
CUtils::dump(1U, "NXDN Network Data Received", data, len);
return len;
return len;
}
return 0U;
}
void CNXDNNetwork::close()

View File

@ -66,9 +66,9 @@ void CNetwork::clock(unsigned int ms)
m_address.s_addr = address.s_addr;
m_port = port;
if (::memcmp(buffer, "NXDNP", 5U) == 0) { // A poll
if (::memcmp(buffer, "NXDNP", 5U) == 0 && length == 15) { // A poll
write(buffer, length);
} else if (::memcmp(buffer, "NXDND", 5U) == 0) {
} else if (::memcmp(buffer, "NXDND", 5U) == 0 && length == 43) {
unsigned char l = length;
m_buffer.addData(&l, 1U);
m_buffer.addData(buffer, length);