Merge branch 'master' into IPv6

This commit is contained in:
Jonathan Naylor 2020-09-05 22:17:07 +01:00
commit 91f04abddb
8 changed files with 55 additions and 5 deletions

View file

@ -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)